File: init

package info (click to toggle)
prometheus-postgres-exporter 0.17.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 900 kB
  • sloc: sh: 374; makefile: 54
file content (44 lines) | stat: -rw-r--r-- 1,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env /lib/init/init-d-script
### BEGIN INIT INFO
# Provides:          prometheus-postgres-exporter
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Prometheus exporter for PostgreSQL server metrics
# Description:       Prometheus exporter for PostgreSQL server metrics, written in Go.
### END INIT INFO

# Author: Martina Ferrari <tina@debian.org>
# Author: Daniel Swarbrick <dswarbrick@debian.org>

DESC="Prometheus exporter for PostgreSQL metrics"
NAME=prometheus-postgres-exporter
USER=prometheus
GROUP=$USER
DAEMON=/usr/bin/$NAME
PIDFILE=/run/prometheus/$NAME.pid
LOGFILE=/var/log/prometheus/$NAME.log

START_ARGS="--no-close --background --make-pidfile"
STOP_ARGS="--remove-pidfile"

do_start_prepare() {
  mkdir -p $(dirname $PIDFILE)
  if test -z "$DATA_SOURCE_NAME"; then
    log_failure_msg \
      "missing \$DATA_SOURCE_NAME -- please edit /etc/default/$NAME"
    exit
  fi
}

do_start_cmd_override() {
  start-stop-daemon --start --quiet --oknodo \
    --exec $DAEMON --pidfile $PIDFILE --user $USER --group $GROUP \
    --chuid $USER:$GROUP $START_ARGS -- $ARGS >>$LOGFILE 2>&1
}

do_stop_cmd_override() {
  start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 \
    --exec $DAEMON --pidfile $PIDFILE --user $USER $STOP_ARGS
}