diff options
Diffstat (limited to 'python-status-exporter/python-status-exporter.init-script')
-rwxr-xr-x | python-status-exporter/python-status-exporter.init-script | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/python-status-exporter/python-status-exporter.init-script b/python-status-exporter/python-status-exporter.init-script new file mode 100755 index 0000000..7f2c661 --- /dev/null +++ b/python-status-exporter/python-status-exporter.init-script @@ -0,0 +1,83 @@ +#!/bin/bash +# +# python-status-exporter Python Status Exporter +# +# chkconfig: 2345 90 10 +# description: python-status-exporter exports statused for promethius +# + +### BEGIN INIT INFO +# Provides: python-status-exporter +# Required-Start: $local_fs $network $remote_fs +# Required-Stop: $local_fs $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start and stop python-status-exporter +# Description: python-status-exporter exports statused for promethius +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +# Source networking configuration. +. /etc/sysconfig/network + +RETVAL=0 +exec_file="/opt/python-status-exporter/python-status-exporter.py" +work_dir="$(dirname $exec_file)" +prog_name="python-status-exporter.py" +py3="/usr/bin/python3" +pidfile="/var/run/${prog_name}.pid" +logfile="/var/log/${prog_name}.log" +loglevel="debug" + + + +conf_check() { + [ -x $exec_file ] || exit 5 +} + +start() { + [ ${NETWORKING} = "no" ] && exit 1 + conf_check + if [ -f "$pidfile" ]; then + if [ -d "/proc/$(cat $pidfile)" ]; then + if [ "$(readlink -- \"/proc/$pidfile/cwd\")" = $work_dir ]; then + echo "$prog_name seems to be running already." + exit -1 + fi + fi + fi + # Start daemons. + cd $work_dir || exit 6 + echo -n $"Starting $proc_name: " + $exec_file -p 9095 -m nginx_vod --pid-file $pidfile --fork -l $logfile -L $loglevel + RETVAL=$? + echo + return $RETVAL +} + +stop() { + # Stop daemons. + echo -n $"Shutting down $proc_name: " + [ -f "$pidfile" ] || echo "No pidfile found at $pidfile, unable to stop $proc_name" && exit 6 + kill $(cat $pidfile) + sleep 1 && test -f "$pidfile" && RETVAL=7 || RETVAL=0 + echo + return $RETVAL +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + *) + echo $"Usage: $0 {start|stop}" + exit 2 +esac + +exit $? |