Skip to content

Instantly share code, notes, and snippets.

@discordianfish
Created February 6, 2015 14:43
Show Gist options
  • Save discordianfish/8faa279cc89d69b7cdfc to your computer and use it in GitHub Desktop.
Save discordianfish/8faa279cc89d69b7cdfc to your computer and use it in GitHub Desktop.
sysvinit prometheus init script
#!/bin/sh
### BEGIN INIT INFO
# Provides: prometheus
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Run Prometheus server
### END INIT INFO
. /lib/lsb/init-functions
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin"
NAME="prometheus"
DESC="Prometheus time series database"
if [ -r "/etc/default/${NAME}" ]
then
. "/etc/default/${NAME}"
fi
set -e
case "${1}" in
start)
log_daemon_msg "Starting Prometheus" $NAME
start-stop-daemon --pidfile /var/run/$NAME.pid --make-pidfile \
--background --exec /usr/bin/writelog --start -- \
/var/log/$NAME.log /usr/local/bin/$NAME -config.file /etc/prometheus.conf $DAEMON_OPTS
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping Prometheus" "$DAEMON"
start-stop-daemon --oknodo --pidfile /var/run/$NAME.pid --stop --retry 10
log_end_msg 0
;;
restart|force-reload)
stop
start
;;
*)
echo "Usage: ${0} {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment