Browse code

Improvement: init.d/debian/wheezy: Add functionality, to restart graceful

Carsten Bock authored on 04/07/2014 13:02:39
Showing 1 changed files
... ...
@@ -85,6 +85,24 @@ case "$1" in
85 85
 		--exec $DAEMON
86 86
 	log_end_msg $?
87 87
 	;;
88
+  restart-graceful)
89
+	log_daemon_msg "Activating shutdown mode: "
90
+	/usr/sbin/sems-stats -c "set_shutdownmode 1"
91
+	CALLS=`/usr/sbin/sems-stats | grep 'Active calls' | awk -F' ' '{print $3}'`
92
+	while [ $CALLS -ne "0" ]
93
+	do
94
+		echo "Current calls $CALLS, waiting..."
95
+		sleep 5
96
+		CALLS=`/usr/sbin/sems-stats | grep 'Active calls' | awk -F' ' '{print $3}'`
97
+	done
98
+	log_daemon_msg "Restarting $DESC: $NAME "
99
+	start-stop-daemon --oknodo --stop --quiet --pidfile \
100
+		$SEMS_PIDFILE --exec $DAEMON
101
+	sleep 5
102
+	start-stop-daemon --start --quiet --pidfile \
103
+		$SEMS_PIDFILE --exec $DAEMON  -- $PARAMS
104
+	echo "."
105
+	;;
88 106
   restart|force-reload)
89 107
 	log_daemon_msg "Restarting $DESC: $NAME "
90 108
 	start-stop-daemon --oknodo --stop --quiet --pidfile \
... ...
@@ -99,7 +117,7 @@ case "$1" in
99 117
        ;;
100 118
   *)
101 119
 	N=/etc/init.d/$NAME
102
-	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
120
+	echo "Usage: $N {start|stop|restart|restart-graceful|force-reload|status}" >&2
103 121
 	exit 1
104 122
 	;;
105 123
 esac