gunicorn.errors.HaltServer

本文详细解析了在使用Gunicorn启动服务时遇到的错误“Worker failed to boot”,通过添加--preload参数成功定位到具体错误原因,即ioc_analyze_report模块中ReportBase类定义时cwd参数未定义。
gunicorn报错gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
 
[root@zq ~]# gunicorn --reload --bind=127.0.0.1:5013 --workers=4 --timeout 180 logquery_service:app
[2020-06-18 13:46:38 +0000] [2068] [INFO] Starting gunicorn 19.7.1
[2020-06-18 13:46:38 +0000] [2068] [INFO] Listening at: http://127.0.0.1:5013 (2068)
[2020-06-18 13:46:38 +0000] [2068] [INFO] Using worker: sync
[2020-06-18 13:46:38 +0000] [2073] [INFO] Booting worker with pid: 2073
[2020-06-18 13:46:38 +0000] [2079] [INFO] Booting worker with pid: 2079
[2020-06-18 13:46:38 +0000] [2085] [INFO] Booting worker with pid: 2085
[2020-06-18 13:46:38 +0000] [2091] [INFO] Booting worker with pid: 2091
/opt/poc/lib/python2.7/site-packages/grequests.py:21: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
  curious_george.patch_all(thread=False, select=False)
/opt/di/server/diserver/IOC/ioc_investigation.py:8: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
/opt/poc/lib/python2.7/site-packages/grequests.py:21: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
  curious_george.patch_all(thread=False, select=False)
/opt/di/server/diserver/IOC/ioc_investigation.py:8: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
/opt/poc/lib/python2.7/site-packages/grequests.py:21: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
  curious_george.patch_all(thread=False, select=False)
/opt/di/server/diserver/IOC/ioc_investigation.py:8: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
/opt/poc/lib/python2.7/site-packages/grequests.py:21: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
  curious_george.patch_all(thread=False, select=False)
/opt/di/server/diserver/IOC/ioc_investigation.py:8: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
Traceback (most recent call last):
  File "/opt/poc/bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==19.7.1', 'console_scripts', 'gunicorn')()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/base.py", line 203, in run
    super(Application, self).run()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/arbiter.py", line 231, in run
    self.halt(reason=inst.reason, exit_status=inst.exit_status)
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/arbiter.py", line 344, in halt
    self.stop()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/arbiter.py", line 393, in stop
    time.sleep(0.1)
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/arbiter.py", line 244, in handle_chld
    self.reap_workers()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/arbiter.py", line 524, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>   ##报错,但看不出具体原因

 

直接看日志看不出具体的错误,需要在gunicorn命令后边加上--preload参数,便可查看详细的报错信息
[root@zq ~]# gunicorn --preload --bind=127.0.0.1:5013 --workers=4 --timeout 180 logquery_service:app
/opt/poc/lib/python2.7/site-packages/grequests.py:21: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
  curious_george.patch_all(thread=False, select=False)
/opt/di/server/diserver/IOC/ioc_investigation.py:8: MonkeyPatchWarning: Patching more than once will result in the union of all True parameters being patched
Traceback (most recent call last):
  File "/opt/poc/bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==19.7.1', 'console_scripts', 'gunicorn')()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/base.py", line 203, in run
    super(Application, self).run()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/arbiter.py", line 60, in __init__
    self.setup(app)
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/arbiter.py", line 120, in setup
    self.app.wsgi()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/opt/poc/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app
    __import__(module)
  File "/opt/di/server/logquery_service.py", line 29, in <module>
  File "/opt/poc/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
    result = _import(*args, **kwargs)
  File "/opt/di/server/diserver/report/ioc_report_handler.py", line 5, in <module>
  File "/opt/poc/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
    result = _import(*args, **kwargs)
  File "/opt/di/server/diserver/report/ioc_analyze_report.py", line 32, in <module>
  File "/opt/di/server/diserver/report/ioc_analyze_report.py", line 42, in ReportBase
NameError: name 'cwd' is not defined         ##可以看到具体的错误是因为cwd参数未定义      

 

 
 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值