Skip to content

Instantly share code, notes, and snippets.

@inklit
Created January 29, 2018 04:05
Show Gist options
  • Save inklit/2cceb86a13b804db06ec51250ce42ee5 to your computer and use it in GitHub Desktop.
Save inklit/2cceb86a13b804db06ec51250ce42ee5 to your computer and use it in GitHub Desktop.
Prometheus openrc for alpine linux
#!/sbin/openrc-run
description="Prometheus"
: ${PROMETHEUS_CONF:=/etc/prometheus/prometheus.yml}
: ${PROMETHEUS_PIDFILE:=/var/run/prometheus.pid}
: ${PROMETHEUS_USER:=root}
depend() {
need net
need localmount
use dns
after firewall
}
start() {
ebegin "Starting Prometheus"
start-stop-daemon --wait 1000 --background --start --exec \
/usr/sbin/prometheus \
--user ${PROMETHEUS_USER} \
--make-pidfile --pidfile ${PROMETHEUS_PIDFILE} \
-- --config.file "${PROMETHEUS_CONF}" --storage.tsdb.path /var/lib/prometheus/ --web.console.templates=/etc/prometheus/consoles --web.console.libraries=/etc/prometheus/console_libraries && \
chown ${PROMETHEUS_USER}:root ${PROMETHEUS_PIDFILE}
eend $?
}
stop() {
ebegin "Stopping Prometheus"
start-stop-daemon --wait 5000 --stop --exec \
/usr/sbin/prometheus \
--user ${PROMETHEUS_USER} \
--pidfile ${PROMETHEUS_PIDFILE} \
-s SIGQUIT
eend $?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment