mirror of
https://git.freebsd.org/ports.git
synced 2025-06-01 10:56:27 -04:00
add -p to daemon to store child process pid Currently the installed gunicorn rc.d script records the PID of the supervisor process to /var/run/gunicorn. This is done by passing "-P" via daemon(8). Record the primary gunicorn worker process in /var/run as well, this will enable better integration with tools like newsyslog(8). For example gunicorn accepts a SIG1 signal to the main worker process to close and reopen logfiles after rotation to the main worker as well as child process. By also passing "-p" to daemon we can then have newsyslog get the appropriate pid to sent a SIG1 to. Here are the docs on the signals gunicorn accepts, as there are other interesting usecases this would enable as well: https://docs.gunicorn.org/en/stable/signals.html PR: 281005 Reported by: pete@nomadlogic.org
40 lines
918 B
Bash
40 lines
918 B
Bash
#!/bin/sh
|
|
#
|
|
# PROVIDE: gunicorn
|
|
# REQUIRE: DAEMON
|
|
# BEFORE: LOGIN
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add the following lines to /etc/rc.conf to enable gunicorn:
|
|
# gunicorn_enable (bool): Set to "NO" by default.
|
|
# Set it to "YES" to enable gunicorn.
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name=gunicorn
|
|
rcvar=gunicorn_enable
|
|
|
|
# set defaults
|
|
|
|
load_rc_config $name
|
|
|
|
: ${gunicorn_enable:=NO}
|
|
: ${gunicorn_config=%%PREFIX%%/etc/gunicorn/gunicorn.conf.py}
|
|
: ${gunicorn_user=%%USERS%%}
|
|
: ${gunicorn_group=%%GROUPS%%}
|
|
|
|
pidfile="/var/run/${name}.pid"
|
|
cpidfile="/var/run/${name}-worker.pid"
|
|
command=/usr/sbin/daemon
|
|
command_args="-P ${pidfile} -p ${cpidfile} -f -ST ${name} %%PREFIX%%/bin/gunicorn -c ${gunicorn_config}"
|
|
required_files="${gunicorn_config}"
|
|
start_precmd="gunicorn_precmd"
|
|
|
|
gunicorn_precmd()
|
|
{
|
|
install -o ${gunicorn_user} /dev/null ${pidfile}
|
|
install -o ${gunicorn_user} /dev/null ${cpidfile}
|
|
}
|
|
|
|
run_rc_command "$1"
|