here you tell it to run it as www:
> daemon_flags="--name netbox --pid /var/run/netbox.pid --user=www --group=www
> --config=${_BASEDIR}/gunicorn.py"
> daemon_flags="${daemon_flags} --log-level=info --log-file=- netbox.wsgi"
but you start as _netbox:
> daemon_user="_netbox"
that won't work, it needs root to change uid (to www).
> pexp="${_BASEDIR}/env/bin/python3.10 ${daemon}${daemon_flags:+
> ${daemon_flags}}"
> echo "pkill -f ${daemon}"
?
> rc_pre() {
> cat <<EOF>/var/run/netbox_start
> APPDIR=${_BASEDIR}/netbox
>
> packages:${APPDIR}${PYTHONPATH:+:${PYTHONPATH}}
> cd ${_BASEDIR}/netbox
> . ${_BASEDIR}/env/bin/activate
> export
> PYTHONPATH=${_BASEDIR}/env/lib/python3.10/site-packages:${APPDIR}${PYTHONPATH:+:${PYTHONPATH}}
> exec gunicorn ${daemon_flags}
> EOF
> chmod u+x /var/run/netbox_start
> chmod o+x /var/run/netbox_start
> }
this doesn't make a lot of sense, why not either start it from the
rc script itself, or save a separate script to disk, rather than
writing to /var/run?
also if you run commands from the venv bin directory, they set
things up for you so you don't need to source "activate".
> rc_stop() {
> pkill -f "${_BASEDIR}/env/bin/gunicorn"
> }
if pexp was set correctly then you wouldn't need to override rc_stop.
> doing rc_check
> [2024-07-25 00:52:55 +0200] [61573] [INFO] Starting gunicorn 22.0.0
> ...
> PermissionError: [Errno 13] Permission denied: '/var/run/tmp5jrbni2l'
> doing _rc_rm_runfile
> (failed)
>
> I don't know why it's trying to create /var/run/tmp5jrbni2l
must be something in gunicorn or netbox.
> If I remove daemon_user="_netbox", everything works
in that case, it starts as root, so it can write there (at least until
it drops privs).
> ii) When I try to stop the process, it doesn't work
> # ps ax | grep /var/www/htdocs/applications/netbox-4.0.7/env/bin/gunicorn
> 61611 p1 S 0:00.75
> /var/www/htdocs/applications/netbox-4.0.7/env/bin/python
> /var/www/htdocs/applications/netbox-4.0.7/env/bin/gunicorn --name netbox
> --pid /var/run/netbox.pid --user=www --group=www
> --config=/var/www/htdocs/appli
...
> # /etc/rc.d/netbox -d stop
> doing _rc_parse_conf
> netbox_flags empty, using default >--name netbox --pid /var/run/netbox.pid
> --user=www --group=www
> --config=/var/www/htdocs/applications/netbox-4.0.7/gunicorn.py
> --log-level=info --log-file=- netbox.wsgi<
> pkill -f /var/www/htdocs/applications/netbox-4.0.7/env/bin/gunicorn
> doing _rc_parse_conf /var/run/rc.d/netbox
> doing rc_check
I didn't check carefully but I guess pexp doesn't match this process,
so rc_check doesn't find it running.
You could try
pexp="/var/www/htdocs/applications/netbox-4.0.7/env/bin/python
/var/www/htdocs/applications/netbox-4.0.7/env/bin/gunicorn --name netbox.*"
--
Please keep replies on the mailing list.