【问题标题】:Upstart Gunicorn doesn't working新贵 Gunicorn 不起作用
【发布时间】:2016-10-28 09:17:18
【问题描述】:

你好,我是韩国学生:)

我正在学习使用 nginx、gunicorn 进行分段、生产测试

首先我想使用套接字运行 gunicorn

gunicorn --bind unix:/tmp/tddtest.com.socket testlists.wsgi:applicaion

它显示

[2016-06-26 05:33:42 +0000] [27861] [INFO] Starting gunicorn 19.6.0
[2016-06-26 05:33:42 +0000] [27861] [INFO] Listening at:  unix:/tmp/tddgoat1.amull.net.socket (27861)
[2016-06-26 05:33:42 +0000] [27861] [INFO] Using worker: sync
[2016-06-26 05:33:42 +0000] [27893] [INFO] Booting worker with pid: 27893

我在本地存储库中运行功能测试

python manage.py test func_test

我正在工作!

Creating test database for alias 'default'...
..
----------------------------------------------------------------------
Ran 2 tests in 9.062s

OK
Destroying test database for alias 'default'...

我想在启动服务器时自动启动 gunicorn

所以我决定使用 Upstart(在 ubuntu 中)

/etc/init/tddtest.com.conf

description "Gunicorn server for tddtest.com"

start on net-device-up
stop on shutdown

respawn

setuid elspeth
chdir /home/elspeth/sites/tddtest.com/source/TDD_Test/testlists/testlists

exec gunicorn --bind \ unix:/tmp/tdd.com.socket testlists.wsgi:application

(wsgi.py的路径是)

/sites/tddtest.com/source/TDD_Test/testlists/testlists

我指挥

sudo start tddtest.com

显示

tddtest.com start/running, process 27905

我认为它正在工作

但我在本地存储库中运行功能测试

python manage.py test func_test

但它显示

======================================================================
FAIL: test_can_start_a_list_and_retrieve_it_later (functional_tests.tests.NewVisitorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
 File "/Users/hanminsoo/Documents/TDD_test/TDD_Test/superlists/functional_tests/tests.py", line 38, in test_can_start_a_list_and_retrieve_it_later
self.assertIn('To-Do', self.browser.title)
AssertionError: 'To-Do' not found in 'Error'

----------------------------------------------------------------------
Ran 2 tests in 4.738s

GUNICORN 不工作ㅠ_ㅠ

我要查看进程

ps aux

但我找不到gunicorn进程

[...]
ubuntu   24387  0.0  0.1 105636  1700 ?        S    02:51   0:00     sshd: ubuntu@pts/0
ubuntu   24391  0.0  0.3  21284  3748 pts/0    Ss   02:51   0:00 -bash
root     24411  0.0  0.1  63244  1800 pts/0    S    02:51   0:00 su -     elspeth
elspeth  24412  0.0  0.4  21600  4208 pts/0    S    02:51   0:00 -su
root     26860  0.0  0.0  31088   960 ?        Ss   04:45   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   26863  0.0  0.1  31524  1872 ?        S    04:45   0:00 nginx: worker process
elspeth  28005  0.0  0.1  17160  1292 pts/0    R+   05:55   0:00 ps aux

我找不到问题...

请有人帮我谢谢:)

【问题讨论】:

  • 您正在运行硒测试吗?这是您唯一需要让服务器运行以进行测试的时间。你的新贵日志告诉你什么?
  • sudo status tddtest.com 的输出是什么?
  • @e4c5 哦.. 我真的很抱歉.. 请原谅我的粗鲁.. 对不起,关于迟到的答案,我正在运行硒测试,但没问题.. 和我尝试查看暴发户日志/var/log/upstart/ 它告诉我/bin/sh: 1: exec: gunicorn: not found
  • 但是当我输入命令行pip install gunicorn时输出是Requirement already satisfied (use --upgrade to upgrade): gunicorn in /home/elspeth/.pyenv/versions/3.5.1/envs/sites/lib/python3.5/site-packages
  • @GoranMiskovic Thang 你先生。米斯科维奇!当我输入命令行sudo status tddtest.com时输出为tddtest.com stop/waiting

标签: django nginx gunicorn upstart


【解决方案1】:

请修改你的upstart脚本如下:

exec /home/elspeth/.pyenv/versions/3.5.1/envs/sites/bin/gunicorn --bind \ unix:/tmp/tdd.com.socket testlists.wsgi:application

如果这不起作用,很可能是因为 /home/elspeth/.pyenv/ 文件夹不可访问,请检查它的权限。如果发现权限正确并且您仍然遇到问题,请尝试以下操作:

script
   cd /home/elspeth/sites/tddtest.com/source/TDD_Test/testlists/testlists
   /home/elspeth/.pyenv/versions/3.5.1/envs/sites/bin/gunicorn --bind \ unix:/tmp/tdd.com.socket testlists.wsgi:application

end script

【讨论】:

  • 我很高兴你的好意!我试试谢谢!
  • 不客气。很抱歉我之前的评论很粗鲁。让我们清理它们:)
  • 谢谢!解决我的问题!!我是工作!!谢谢!! ㄴ(^O^)ㄱ
猜你喜欢
  • 1970-01-01
  • 2014-06-12
  • 2014-03-30
  • 1970-01-01
  • 2014-01-21
  • 2019-06-15
  • 2015-03-30
  • 2012-05-29
  • 1970-01-01
相关资源
最近更新 更多