1

我试图让 NewRelic python 代理与我的主管和 gunicorn 一起使用,但无法让它工作。

这是我当前有效的主管设置:

[program:gunicorn]
directory = /home/<USER>/.virtualenvs/<DOMAIN>/myproject/
command=/home/<USER>/.virtualenvs/<DOMAIN>/bin/gunicorn my_project.wsgi:application

我试图这样做:

[program:gunicorn]
directory = /home/<USER>/.virtualenvs/<DOMAIN>/myproject/

#Working command
#command=/home/<USER>/.virtualenvs/<DOMAIN>/bin/gunicorn myproject.wsgi:application


command=/home/<USER>/.virtualenvs/<DOMAIN>/bin/newrelic-admin run-program /home/<USER>/.virtualenvs/<DOMAIN>/bin/gunicorn myproject.wsgi:application
environment=NEW_RELIC_CONFIG_FILE=/home/<USER>/.virtualenvs/<DOMAIN>/myproject/newrelic.ini

user = <USER>
autostart = true
autorestart = true
stderr_events_enabled = true
redirect_stderr = true
stdout_logfile = /home/<USER>/logs/gunicorn.log
stderr_logfile = /home/<USER>/logs/gunicorn_err.log

但后来我得到这个错误:

Traceback (most recent call last):
  File "/home/user/.virtualenvs/domain.com/lib/python2.7/site.py", line 688, in <module>
    main()
  File "/home/user/.virtualenvs/domain.com/lib/python2.7/site.py", line 679, in main
    execsitecustomize()
  File "/home/user/.virtualenvs/domain.com/lib/python2.7/site.py", line 547, in execsitecustomize
    import sitecustomize
  File "/home/user/.virtualenvs/domain.com/local/lib/python2.7/site-packages/newrelic-1.10.2.38-py2.7-linux-x86_64.egg/newrelic/bootstrap/sitecustomize.py", line 74, in <module>
    newrelic.agent.initialize(config_file, environment)
  File "/home/user/.virtualenvs/domain.com/local/lib/python2.7/site-packages/newrelic-1.10.2.38-py2.7-linux-x86_64.egg/newrelic/config.py", line 1456, in initialize
    log_file, log_level)
  File "/home/user/.virtualenvs/domain.com/local/lib/python2.7/site-packages/newrelic-1.10.2.38-py2.7-linux-x86_64.egg/newrelic/config.py", line 383, in _load_configuration
    'Unable to open configuration file %s.' % config_file)
newrelic.api.exceptions.ConfigurationError: Unable to open configuration file /.

newrelic.ini 文件在该路径上,那么我做错了什么?

编辑:

newrelic.ini 文件的路径是:

/home/<USER>/.virtualenvs/<DOMAIN>/myproject/newrelic.ini
4

3 回答 3

5

环境需要报价才能工作。

这是一个工作设置:

[program:gunicorn]
directory = /home/<USER>/.virtualenvs/<DOMAIN>/<PROJECT>/
command=/home/<USER>/.virtualenvs/<DOMAIN>/bin/newrelic-admin run-program /home/<USER>/.virtualenvs/<DOMAIN>/bin/gunicorn <PROJECT>.wsgi:application
environment=NEW_RELIC_CONFIG_FILE="/home/<USER>/.virtualenvs/<DOMAIN>/<PROJECT>/newrelic.ini"

user = <USER>
autostart = true
autorestart = true
stderr_events_enabled = true
redirect_stderr = true
stdout_logfile = /home/<USER>/logs/gunicorn.log
stderr_logfile = /home/<USER>/logs/gunicorn_err.log
于 2013-04-19T09:13:20.533 回答
1

您没有使用 newrelic-admin 作为使用 gunicorn 时的首选方法。利用:

[program:gunicorn]
directory = /home/user/.virtualenvs/domain.com/my_project/
command=/home/user/.virtualenvs/domain.com/bin/newrelic-admin run-program /home/user/.virtualenvs/domain.com/bin/gunicorn my_project.wsgi:application
environment=NEW_RELIC_CONFIG_FILE=/home/user/.virtualenvs/domain.com/bin/newrelic.ini

无需更改 wsgi.py 文件中的任何内容。

为什么你在 bin 目录中有 newrelic.ini 文件我不知道。您通常会将它与您的项目一起使用,但是您的项目也在 virtualenv 下,这也有点奇怪。

要从 supervisord 传递环境变量,请参见:

有关 newrelic-admin 命令以及如何将其与 gunicorn 一起使用的详细信息,请参阅:

于 2013-04-18T01:40:59.117 回答
0

好吧,我面临着同样的问题。我得到以下结果:

warpdrive: ERROR (no such file)

不幸的是,在对 supervisord.conf 文件进行任何更改后,我没有更新 supervisorctl。因此,无论何时更改 supervisord.conf 文件,然后重新运行以下 cmd :

sudo supervisorctl update

然后运行:

sudo supervisorctl restart all

干杯!

于 2016-05-24T08:57:32.010 回答