summaryrefslogtreecommitdiff
path: root/network/graphite-carbon/rc.carbon-cache
blob: ee7c98630e3a7132d8e2eea45f0da4678355d67a (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
#
# Start/stop/restart the carbon-cache daemon
# Written by Mario Preksavec <mario@slackware.hr>

BIN_FILE=/usr/bin/carbon-cache
PID_FILE=/var/run/carbon-cache.pid
CONF_FILE=/etc/carbon/carbon.conf

rc_start() {
  if [ -x $BIN_FILE ] && [ -f $CONF_FILE ]; then
    if [ -f $PID_FILE ] && kill -0 $(cat $PID_FILE) 2>/dev/null; then
      echo "carbon-cache daemon already running"
    else
      echo "Starting carbon-cache daemon:  $BIN"
      $BIN_FILE --config=$CONF_FILE --pidfile=$PID_FILE start
    fi
  fi
}

rc_stop() {
  if [ -f $PID_FILE ] && kill -0 $(cat $PID_FILE) 2>/dev/null; then
    echo "Stopping carbon-cache daemon:  $BIN"
    $BIN_FILE --config=$CONF_FILE --pidfile=$PID_FILE stop \
      && rm -f $PID_FILE
  fi
}

rc_status() {
  if [ -f $PID_FILE ] && kill -0 $(cat $PID_FILE) 2>/dev/null; then
    $BIN_FILE --config=$CONF_FILE --pidfile=$PID_FILE status
  fi
}

rc_restart() {
  rc_stop
  sleep 1
  rc_start
}

case "$1" in
  'start')
    rc_start
  ;;
  'stop')
    rc_stop
  ;;
  'restart')
    rc_restart
  ;;
  'status')
    rc_status
  ;;
  *)
    echo "usage $0 start|stop|restart|status"
  ;;
esac