: ${petio_group:="petio"}
: ${petio_data_dir:="/usr/local/petio"}
export NODE_ENV=production
export APP_DIR=/usr/local/share/petio
export VIEWS_FOLDER=/usr/local/share/petio/pkg/
export DATA_FOLDER=${petio_data_dir}
pidfile="/var/run/${name}/${name}.pid"
start_precmd="petio_precmd"
procname="/usr/local/bin/node"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} ${procname} --no-warnings /usr/local/share/petio/pkg/api/dist/main.js --host 0.0.0.0 --port 7777"
if [ ! -d $(dirname ${pidfile}) ]; then
install -d -o ${petio_user} -g ${petio_group} $(dirname ${pidfile})
if [ ! -d ${petio_data_dir} ]; then
install -d -o ${petio_user} -g ${petio_group} ${petio_data_dir}
# make sure mongod is running
if ! checkyesno mongod_enable && \
! /usr/local/etc/rc.d/mongod forcestatus 1>/dev/null 2>&1; then
echo "Make sure to enable and start mongod"
/usr/local/etc/rc.d/mongod forcestart || return 1