Skip to content

Instantly share code, notes, and snippets.

@mche
Created November 9, 2018 11:43
Show Gist options
  • Save mche/c1c1bdc0d08b2bf6ef7a64338702fc98 to your computer and use it in GitHub Desktop.
Save mche/c1c1bdc0d08b2bf6ef7a64338702fc98 to your computer and use it in GitHub Desktop.
#!/sbin/openrc-run
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_commands="clean_cache"
extra_started_commands="reload upgrade force_stop"
#~ extra_stopped_commands="clean-cache-start"
description="Веб-система СоюзОСТ"
ROOT=/home/guest/Ostanin
# только старт гипнотода, далее только пидфайл
SCRIPT=$ROOT/script/app.sh
LOG=log/mojo.log
CACHE=$ROOT/static/cache/*
USER=guest # su
GROUP=guest
#Note that this value can only be changed after the server has been stopped.
PIDFILE=$ROOT/hypnotoad.pid
depend() {
use net
after postgresql
}
#~ start() {
#~ ebegin "Starting $SCRIPT"
#~ start-stop-daemon --start --user $USER --exec $SCRIPT # там 2>/dev/null
#~ local retval=$?
#~ if [ $retval -ne 0 ] ; then
#~ eerror "ошибка в логе $LOG"
#~ fi
#~ eend $retval
#~ }
start() {
ebegin "Starting [$description]"
su - $USER -c \
"cd ~/Ostanin; \
source ~/.bashrc; \
perlbrew use perl-5.26.1; \
MOJO_MODE=production; \
hypnotoad script/app.pl 2>/dev/null; "
local retval=$?
if [ $retval -ne 0 ] ; then
eerror "ошибка в логе ${ROOT}/${LOG}"
fi
eend $retval
}
stop() {
ebegin "Gracefully stopping [$description]"
start-stop-daemon --signal 3 --pidfile $PIDFILE
local retval=$?
if [ $retval -ne 0 ] ; then
eerror "видимо не запущен"
fi
eend $retval
}
#~ reload() {
#~ upgrade()
#~ }
upgrade() {
ebegin "Upgrade (hot deployment) [$description]"
start-stop-daemon --signal 12 --pidfile $PIDFILE
local retval=$?
if [ $retval -ne 0 ] ; then
eerror "видимо не запущен"
fi
eend $retval
}
force_stop() {
ebegin "Immediately stoping [$description]"
start-stop-daemon --signal 15 --pidfile $PIDFILE
local retval=$?
if [ $retval -ne 0 ] ; then
eerror "видимо не запущен"
fi
eend $retval
}
clean_cache() {
ebegin "Cleaning $CACHE of [$description]"
rm -rf $CACHE
eend $retval
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment