我正在尝试运行一个附带python app的gunicorn,但它一直给我failed to find application
错误。
这是完整的痕迹:
[2018-03-06 22:17:39 +0000] [13278] [INFO] Starting gunicorn 19.7.1
[2018-03-06 22:17:39 +0000] [13278] [INFO] Listening at: http://0.0.0.0:7007 (13278)
[2018-03-06 22:17:39 +0000] [13278] [INFO] Using worker: gthread
[2018-03-06 22:17:39 +0000] [13281] [INFO] Booting worker with pid: 13281
[2018-03-06 22:17:39 +0000] [13285] [INFO] Booting worker with pid: 13285
[2018-03-06 22:17:39 +0000] [13286] [INFO] Booting worker with pid: 13286
[2018-03-06 22:17:39 +0000] [13290] [INFO] Booting worker with pid: 13290
Failed to find application: 'production.server'
[2018-03-06 22:17:42 +0000] [13281] [INFO] Worker exiting (pid: 13281)
Failed to find application: 'production.server'
Failed to find application: 'production.server'
[2018-03-06 22:17:42 +0000] [13285] [INFO] Worker exiting (pid: 13285)
[2018-03-06 22:17:42 +0000] [13290] [INFO] Worker exiting (pid: 13290)
Failed to find application: 'production.server'
[2018-03-06 22:17:42 +0000] [13286] [INFO] Worker exiting (pid: 13286)
[2018-03-06 22:17:42 +0000] [13278] [INFO] Shutting down: Master
[2018-03-06 22:17:42 +0000] [13278] [INFO] Reason: App failed to load.
我的文件树显示production/server.py
确实存在。我正在运行bash命令:
gunicorn \
-b 0.0.0.0:${port} \
-k gthread \
-w ${proc_count} \
--threads ${thread_count} \
-t 300 \
'production.server:create_app(ensemble)'
当我扎根于包含production
子目录的目录时。
当我直接从bash运行Gunicorn
命令时:
gunicorn production.server:create_app -b 0.0.0.0:7007
它工作得很好! 我该如何解决这个问题?