我试图让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

===============>>#1 票数:6 已采纳

环境需要引号才能起作用。

这是一个有效的设置:

[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

===============>>#2 票数:1

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

[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下,这也有些奇怪。

有关从supervisor传递环境变量的信息,请参见:

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

===============>>#3 票数:0

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

warpdrive: ERROR (no such file)

对我来说,我在更改supervisord.conf文件后没有更新supervisorctl。 所以,无论何时更改supervisord.conf文件,然后重新运行cmd:

sudo supervisorctl update

然后运行:

sudo supervisorctl restart all

干杯!

  ask by Tomas Jacobsen translate from so

未解决问题?本站智能推荐: