【问题标题】:gunicorn and python doesn't work when i close the bash terminal当我关闭 bash 终端时 gunicorn 和 python 不起作用
【发布时间】:2019-03-20 07:32:24
【问题描述】:

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

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

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

 ps -C gunicorn

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

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

我可以在 gunicorn 上放一个“永远”(就像我们在 node.js 上放的一样),或者从 bash 中分离 gunicorn 和 virtualenv,以便始终独立于关闭运行 狂欢?

我该如何解决这个问题?

【问题讨论】:

    标签: python-2.7 centos virtualenv gunicorn


    【解决方案1】:

    可能 nohup 会有所帮助

    nohup your command
    

    What's the difference between nohup and ampersand

    还要检查 --daemon 选项,它可能类似于 forewer,有关详细信息和其他建议,请参阅

    What is the correct way to leave gunicorn running?

    【讨论】:

      【解决方案2】:

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

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

      --daemon 选项对我有用!

      【讨论】:

        猜你喜欢
        • 2016-09-23
        • 1970-01-01
        • 2015-10-23
        • 2020-09-19
        • 1970-01-01
        • 1970-01-01
        • 2014-09-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多