我有一个非常简单的FLASK Web服务器,我在heroku平台的Web dyno中运行。我也有一个非常简单的python程序,该程序在单独的dyno上运行,它会打印“ hello world”,然后退出。
我的procfile看起来像这样
web: gunicorn --bind 0.0.0.0:$PORT wsgi
test: python helloWorld.py
在heroku local上,您好,世界程序结束后,网络测功机也会被杀死:
$ heroku local
8:54:29 AM test.1 | Hello World
[DONE] Killing all processes with signal SIGINT
8:54:29 AM test.1 Exited Successfully
8:54:29 AM web.1 | Traceback (most recent call last):
8:54:29 AM web.1 | File "/anaconda3/bin/gunicorn", line 7, in <module>
8:54:29 AM web.1 | from gunicorn.app.wsgiapp import run
8:54:29 AM web.1 | File "/anaconda3/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 9, in <module>
8:54:29 AM web.1 | from gunicorn.app.base import Application
8:54:29 AM web.1 | File "/anaconda3/lib/python3.7/site-packages/gunicorn/app/base.py", line 11, in <module>
8:54:29 AM web.1 | from gunicorn._compat import execfile_
8:54:29 AM web.1 | File "/anaconda3/lib/python3.7/site-packages/gunicorn/_compat.py", line 267, in <module>
8:54:29 AM web.1 | import inspect
8:54:29 AM web.1 | File "/anaconda3/lib/python3.7/inspect.py", line 1087, in <module>
8:54:29 AM web.1 | 'args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations')
8:54:29 AM web.1 | File "/anaconda3/lib/python3.7/collections/__init__.py", line 397, in namedtuple
8:54:29 AM web.1 | exec(s, namespace)
8:54:29 AM web.1 | File "<string>", line 1, in <module>
8:54:29 AM web.1 | KeyboardInterrupt
8:54:29 AM web.1 Exited with exit code null
如何防止这种情况?
我知道问题出在helloWorld.py退出了。如果我创建的脚本不会终止,则不会发生此问题。
print("Hello World", flush=True)
while True:
pass
答案 0 :(得分:0)