#!/bin/ksh
# Author: Zhang Huangbin <zhb@iredmail.org>
# Purpose: Start/stop iRedAdmin uwsgi instance.

RUN_DIR='/var/run/iredadmin'
PID_FILE="${RUN_DIR}/iredadmin.pid"
UWSGI_INI_FILE='/opt/www/iredadmin/rc_scripts/uwsgi/openbsd.ini'

daemon="/usr/local/bin/uwsgi --ini ${UWSGI_INI_FILE} --log-syslog --pidfile ${PID_FILE} --daemonize /dev/null"
daemon_user='iredadmin'
daemon_group='iredadmin'

. /etc/rc.d/rc.subr

rc_pre() {
    install -d -o ${daemon_user} -g ${daemon_group} -m 0775 ${RUN_DIR}
}

rc_stop() {
    kill -INT `cat ${PID_FILE}`
}

rc_cmd $1
