【问题标题】:gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3> django projectgunicorn.errors.HaltServer: <HaltServer 'Worker 无法启动。' 3> django项目
【发布时间】:2018-08-20 21:25:32
【问题描述】:

独角兽状态

gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor
Active: failed (Result: exit-code) since Mon 2018-03-12 18:30:15 UTC;
Process: 3535 ExecStart=/home/mike/movingcollage/movingcollageenv/bin/
Main PID: 3535 (code=exited, status=1/FAILURE)

Mar 12 18:30:15 ubuntu-2gb-nyc3-01 gunicorn[3535]:   File "/home/mike/mo
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 gunicorn[3535]:     time.sleep(0.1)
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 gunicorn[3535]:   File "/home/mike/mo
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 gunicorn[3535]:     self.reap_workers
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 gunicorn[3535]:   File "/home/mike/mo
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 gunicorn[3535]:     raise HaltServer( 
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 gunicorn[3535]: gunicorn.errors.HaltS
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 systemd[1]: gunicorn.service: Main pr
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 systemd[1]: gunicorn.service: Unit en
Mar 12 18:30:15 ubuntu-2gb-nyc3-01 systemd[1]: gunicorn.service: Failed
29 ubuntu-2gb-nyc3-01 systemd[1]: gunicorn.service: Failed

nginx错误日志:

2018/03/12 04:59:08 [error] 1562#1562: *1787 connect() to unix:/home/mik
e/movingcollage/movingcollage.sock failed (111: Connection refused) whil
e connecting to upstream, client: 107.205.110.154, server: movingcollage
.com, request: "GET / HTTP/1.1", upstream: "http://unix:/home/mike/movin
gcollage/movingcollage.sock:/", host: "movingcollage.com"

我的配置没问题,这曾经可以工作;我提取了一些新的应用程序代码,现在收到 502 bad gateway 错误(在我提取应用程序代码之前,站点运行良好)。我已经做了service gunicorn restartsystemctl restart gunicorn 并且仍然收到 502 bad gateway 错误。有人可以帮忙吗?

这是一个 django 项目,物有所值。

Gunicorn 配置:

description "Gunicorn application server handling movingcollage"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
setuid user
setgid www-data
chdir /home/mike/movingcollage

exec movingcollageenv/bin/gunicorn --workers 3 --bind unix:/home/mike/movingcollage/movingcollage.sock movingcollage.wsgi:application

gunicorn --bind=unix:/home/mike/movingcollage/movingcollage.sock movingcollage.wsgi.application

root@ubuntu-2gb-nyc3-01:/etc/init# gunicorn --bind=unix:/home/mike/movingcollage/movingcollage.sock movingcollage.wsgi:application
Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py",
 line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", li
ne 185, in run
    super(Application, self).run()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", li
ne 71, in run
    Arbiter(self).run()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", lin
e 169, in run
    self.manage_workers()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", lin
e 477, in manage_workers
    self.spawn_workers()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", lin
e 542, in spawn_workers
    time.sleep(0.1 * random.random())
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", lin
e 209, in handle_chld
    self.reap_workers()
 File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", lin
e 459, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

【问题讨论】:

  • 这里没有有用的信息。至少获取包含 gunicorn[3535] 的其余行
  • @hop 我添加了来自gunicorn --bind=unix:/home/mike/movingcollage/movingcollage.sock movingcollage.wsgi.application 的行,这与 gunicorn[3535] 中的行相同(行已切断,我无法粘贴)

标签: python django nginx gunicorn


【解决方案1】:

运行 gunicorn --bind=unix:/home/mike/movingcollage/movingcollage.sock movingcollage.wsgi:application --preload --loglevel=debug 并在解决导入错误后让它继续运行

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    • 1970-01-01
    • 2015-02-01
    • 2018-08-24
    相关资源
    最近更新 更多