Permalink
Browse files

example: fix status and restart for init.d

Signed-off-by: Laurent Arnoud <laurent.arnoud@af83.com>
Signed-off-by: Julien Boyer <julien.boyer@af83.com>
  • Loading branch information...
spk committed Mar 14, 2013
1 parent 8641404 commit 1d4ef4f971be5951198f7a1cb73cd61a551e23dc
Showing with 13 additions and 18 deletions.
  1. +13 −18 examples/pids.init.d.sh
View
@@ -43,7 +43,7 @@ SCRIPTNAME=/etc/init.d/$NAME
do_start()
{
su -l -c "source $PROFILE; $DAEMON start -d" $APP_USER
- RETVAL="$?"
+ RETVAL="$?"
return "$RETVAL"
}
@@ -53,10 +53,19 @@ do_start()
do_stop()
{
su -l -c "source $PROFILE; $DAEMON stop" $APP_USER
- RETVAL="$?"
+ RETVAL="$?"
return "$RETVAL"
}
+#
+# Function that restarts the daemon/service
+#
+do_restart()
+{
+ su -l -c "source $PROFILE; $DAEMON restart" $APP_USER
+ RETVAL="$?"
+ return "$RETVAL"
+}
case "$1" in
start)
@@ -76,29 +85,15 @@ case "$1" in
esac
;;
status)
- status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ status_of_proc "${NAME}_supervisor" && exit 0 || exit $?
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;; # Old process is still running
- *) log_end_msg 1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- ;;
- esac
+ do_restart
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2

0 comments on commit 1d4ef4f

Please sign in to comment.