morss/morss-helper

41 lines
790 B
Plaintext
Raw Normal View History

#! /bin/sh
if ! command -v python && command -v python3 ; then
alias python='python3'
fi
2021-12-28 15:30:20 +00:00
function run {
gunicorn --bind 0.0.0.0:${PORT:-8000} --preload --access-logfile - morss
}
2021-12-28 15:30:20 +00:00
function daemon {
gunicorn --bind 0.0.0.0:${PORT:-8000} --preload --access-logfile - --daemon morss
}
2021-11-24 20:23:16 +00:00
2021-12-28 15:30:20 +00:00
function reload {
pid=$(pidof 'gunicorn: master [morss]') # NB. requires python-setproctitle
if [ -z "$pid" ]; then
# if gunicorn is not currently running
daemon
2021-11-24 20:23:16 +00:00
2021-12-28 15:30:20 +00:00
else
kill -s USR2 $pid
kill -s WINCH $pid
sleep 1 # give gunicorn some time to reload
kill -s TERM $pid
2021-12-25 17:21:55 +00:00
2021-12-28 15:30:20 +00:00
fi
}
function check {
2021-12-27 15:08:55 +00:00
python -m morss.crawler http://localhost:${PORT:-8000}/ > /dev/null 2>&1
2021-12-28 15:30:20 +00:00
}
if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$(type -t "$1")" = "function" ]; then
$@
2021-12-27 15:08:55 +00:00
else
2021-12-28 15:30:20 +00:00
python -m morss $@
2021-11-24 20:23:16 +00:00
fi