FreeBSD/jails/config/auto/portfolio
2021-02-13 11:38:38 -08:00

53 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# Copyright (c) 2018-2021, diyIT.org
# All rights reserved.
#
# BSD 2-Clause License ("Simplified BSD License" or "FreeBSD License")
# https://diyit.org/license/
#
#
# the two lines below are not just comments but required by rcorder; service -e
# PROVIDE: portfolio
# REQUIRE: NETWORKING DAEMON
. /etc/rc.subr
: ${portfolio_enable="NO"}
name=portfolio
port=8000
appdir="/data/${name}"
rcvar=${name}_enable
GUNICORN_CMD="/usr/local/bin/gunicorn -D -b unix:/var/run/${name}.sock --log-file /var/log/${name}.log \
--chdir ${appdir} ${name}.wsgi"
# GUNICORN_CMD="/usr/local/bin/gunicorn -D -b 0.0.0.0:${port} -b [::]:${port} --log-file /var/log/${name}.log \
# --chdir ${appdir} ${name}.wsgi"
start_cmd="server_start"
stop_cmd="server_stop"
restart_cmd="server_restart"
server_start()
{
$GUNICORN_CMD
}
server_stop()
{
ps ax | grep -ie "gunicorn: master \[${name}.wsgi\]" | grep -v grep | awk '{print $1}' | xargs kill -9
ps ax | grep -ie "gunicorn: worker \[${name}.wsgi\]" | grep -v grep | awk '{print $1}' | xargs kill -9
}
server_restart()
{
ps ax | grep -ie "gunicorn: master \[${name}.wsgi\]" | grep -v grep | awk '{print $1}' | xargs kill -9
server_start
}
load_rc_config ${name}
run_rc_command "$1"