当我关闭 bash 终端时,gunicorn 和 python 不工作

gunicorn and python doesn't work when i close the bash terminal

我在 centos 机器上有一个 python 程序 运行ning。我使用 virtualenv (source activate) 来激活特定的 python 然后我使用以下命令:

gunicorn -t 10000 -b 0.0.0.0:1234 start:app &

它工作正常。但是当我关闭 bash 时,我的程序就不再工作了。当我打开一个新的 bash(通过 PUTTY),然后输入

 ps -C gunicorn

我看到 gunicorn 进程 运行ning。 如果我把所有这些都放在 local.rc 上(与服务器一起初始化)一切正常。

我有两个问题。第一个是:

我可以把 "forever" 放在 gunicorn 上吗(就像我们放在 node.js 上一样),或者从 bash 中分离 gunicorn 和 virtualenv,以便始终 运行独立于关闭 bash?

我该如何解决这个问题?

nohup 可能会有帮助

nohup your command

What's the difference between nohup and ampersand

同时检查 --daemon 选项,它可能与 forewer 类似,有关详细信息和其他建议,请参见

What is the correct way to leave gunicorn running?

我找到了答案。我尝试使用 nohup,但没有成功。现在我正在使用

gunicorn -t 10000 -b 0.0.0.0:1234 start:app  --daemon &

--daemon 选项对我有用!