如何重新启动gunicorn hup,我不知道masterpid或PID文件的位置

问题描述 投票:1回答:4

我想重新启动一个使用gunicorn运行的Django服务器。

我知道如何在我的系统中使用gunicorn。但是现在我需要重新启动一个我没有设置的远程服务器。

我不知道masterpid重启服务器我怎样才能获得masterPID。

通常我HUP gunicorn与sudo kill -s HUP masterpid

我试过ps aux|grep gunicorn

我没有在任何地方找到gunicorn.pid文件。

我怎样才能获得masterpid

django gunicorn
4个回答
7
投票
pstree -ap|grep gunicorn

这将为您提供树结构,因为您可以找到master(父级),并且在gunicorn旁边您可以找到PID(数字)


7
投票

您可以使用选项'-p'运行gunicorn,这样您就可以从pid文件中获取主进程的pid。例如:

gunicorn -p app.pid your_app.wsgi.app

你可以通过以下方式获得主人的pid:

cat app.pid

0
投票

这也应该重新启动gunicorn:

ps aux |grep gunicorn |grep yourapp | awk '{ print $2 }' |xargs kill -HUP

0
投票

第1步:转到/etc/systemd/system/gunicorn.service并打开文件添加波纹管线

PIDFile=/run/gunicorn/gunicorn.pid  
--pid /run/gunicorn/gunicorn.pid

例:

[Service]
PIDFile=/run/gunicorn/gunicorn.pid
WorkingDirectory=/home/django/django_project
ExecStart=/usr/bin/gunicorn --pid /run/gunicorn/gunicorn.pid --name=django_project.....
User=django
Group=django

第2步:转到/etc/tmpfiles.d/并创建新文件gunicorn.conf(如果不存在)

添加下面的行

d /run/gunicorn 0755 django django -

其中django =用户名和组名

步骤3:重新启动服务器或/etc/init.d/gunicorn restart以重新启动gunicorn以使其生效

你的pid文件位置是/run/gunicorn/gunicorn.pid现在检查..

© www.soinside.com 2019 - 2024. All rights reserved.