#!/sbin/openrc-run
name="man.sr.ht"
description="man.sr.ht service"
supervisor=supervise-daemon
MAN_USER=${MAN_USER:-man}
MAN_BIND=${MAN_BIND:-127.0.0.1:5004}
MAN_GUNICORN_CONF=${MAN_GUNICORN_CONF:-/etc/sr.ht/man.sr.ht.gunicorn.conf.py}
MAN_ARGS=${MAN_ARGS:-}
LOGS=/var/log/man.sr.ht.log
prometheus_multiproc_dir=/run/man.sr.ht
supervise_daemon_args="-1 $LOGS -2 $LOGS -e prometheus_multiproc_dir=$prometheus_multiproc_dir"
command="/usr/bin/gunicorn"
command_args="mansrht.app:app -b $MAN_BIND -c $MAN_GUNICORN_CONF $MAN_ARGS"
command_user="$MAN_USER:$MAN_USER"
pidfile="/run/${RC_SVCNAME}.pid"
depend() {
need net
use redis
use postgresql
use pgbouncer
}
start_pre() {
checkpath -f "$LOGS" -m 644 -o "$MAN_USER:$MAN_USER"
# Workaround for https://github.com/OpenRC/openrc/issues/335
if [ -n "$prometheus_multiproc_dir" ]
then
checkpath -d "$prometheus_multiproc_dir" -m 775 -o "$MAN_USER:$MAN_USER"
rm -rf "$prometheus_multiproc_dir"/*
fi
}