#!/bin/sh # # Copyright (c) 2018 Wind River Systems, Inc. # # The right to copy, distribute, modify, or otherwise make use # of this software may be licensed only pursuant to the terms # of an applicable Wind River license agreement. # ### BEGIN INIT INFO # Provides: Gnocchi metricd # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Gnocchi metricd service ### END INIT INFO RETVAL=0 DESC="gnocchi-metricd" DAEMON="/usr/bin/gnocchi-metricd" PIDFILE="/var/run/$DESC.pid" CONFIGFILE="/etc/gnocchi/gnocchi.conf" LOGFILE="/var/log/gnocchi/metricd.log" start() { if [ -e $PIDFILE ]; then PIDDIR=/proc/$(cat $PIDFILE) if [ -d ${PIDDIR} ]; then echo "$DESC already running." return else echo "Removing stale PID file $PIDFILE" rm -f $PIDFILE fi fi echo -n "Starting $DESC..." start-stop-daemon --start --quiet --background --pidfile ${PIDFILE} \ --make-pidfile --exec ${DAEMON} -- --config-file ${CONFIGFILE} \ --log-file ${LOGFILE} RETVAL=$? if [ $RETVAL -eq 0 ]; then echo "Gnocchi metricd started." else echo "Gnocchi metricd start failed." fi } stop() { if [ ! -e $PIDFILE ]; then echo "Gnocchi metricd already stopped." return fi echo -n "Stopping $DESC..." start-stop-daemon --stop --quiet --pidfile $PIDFILE RETVAL=$? if [ $RETVAL -eq 0 ]; then echo "Gnocchi metricd stopped." else echo "Gnocchi metricd stop failed." fi rm -f $PIDFILE } status() { pid=`cat $PIDFILE 2>/dev/null` if [ -n "$pid" ]; then if ps -p $pid &> /dev/null ; then echo "$DESC is running" RETVAL=0 return else echo "$DESC is not running but has pid file" RETVAL=1 fi fi echo "$DESC is not running" RETVAL=3 } case "$1" in start) start ;; stop) stop ;; restart|force-reload|reload) stop start ;; status) status ;; *) echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" RETVAL=1 ;; esac exit $RETVAL