【问题标题】:fabric kill gunicorn process and restart织物杀死gunicorn进程并重新启动
【发布时间】:2015-10-08 11:38:39
【问题描述】:

我正在使用使用 gunicorn 的结构进行站点部署。 我有以下由deploy() 函数调用的代码。

def restart_gunicorn():
    sudo('ps ax|grep gunicorn')
    sudo('pkill -HUP -f [g]unicorn.*master')
    sudo('gunicorn -b 0.0.0.0:8080 %(path)s/application/wsgi &' % env)

当我运行我的 fab 文件时,它显示如下:

    out:  7694 pts/18   S+     0:00 grep gunicorn
[127.0.0.1:2222] out: 

[127.0.0.1:2222] sudo: pkill -HUP -f [g]unicorn.*master
[127.0.0.1:2222] out: sudo password:
[127.0.0.1:2222] out: 

Fatal error: sudo() received nonzero return code 1 while executing!

Requested: pkill -HUP -f [g]unicorn.*master

我认为它应该杀死 gunicorn 并重新启动它.. 我在这里错过了什么??

【问题讨论】:

    标签: python django fabric gunicorn


    【解决方案1】:

    那是因为您的 gunicorn 进程没有完全命名为 gunicorn 并且您可能有多个 gunicorn 进程正在运行(主进程和工作进程)。

    通常是你想要杀死的主人。你很少想把它干掉,更多的时候你只是想重新加载你的代码,所以 -HUP 就足够了。所以试试这个:

    sudo('pkill -HUP -f [g]unicorn.*master')    
    

    根据您的 cmets,您的大部分问题似乎是由于 Gunicorn 根本没有在您的系统上运行。有两种选择,可以先做个测试,也可以直接用warn_only

    with settings(warn_only=True):
        sudo('pkill -HUP -f [g]unicorn.*master')
        sudo('gunicorn -b 0.0.0.0:8080 %(path)s/application/wsgi &' % env)
    

    请注意,此处不需要您的 sudo('ps ax|grep gunicorn') 行。

    【讨论】:

    • 输出:7694 pts/18 S+ 0:00 grep gunicorn [127.0.0.1:2222] 输出:[127.0.0.1:2222] sudo:pkill -HUP -f [g]unicorn.*master [127.0.0.1:2222] 输出:sudo 密码:[127.0.0.1:2222] 输出:致命错误:sudo() 在执行时收到非零返回码 1!请求:pkill -HUP -f [g]unicorn.*master
    • repeat: "用 ps ax|grep gunicorn 的输出更新问题"
    • 你在哪里添加了来自 ps -ax| 的输出grep 独角兽?我当然在任何地方都看不到它。如果我没有通过:请登录到您的服务器。键入 ps -ax| grep gunicorn,从该命令复制并输出,编辑问题并将其粘贴到那里。
    • 7694 pts/18 S+ 0:00 grep gunicorn 是 ps ax|grep 的输出
    • 9368 pts/16 S+ 0:00 grep --color=auto gunicorn 可能你正在寻找这个
    【解决方案2】:

    我用这个:

    sudo('reload gunicorn')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      相关资源
      最近更新 更多