Skip to content
Extraits de code Groupes Projets
Valider a0c6c175 rédigé par Alec Leamas's avatar Alec Leamas
Parcourir les fichiers

websocket service cleanup

Complete implementation of the websocket service as a separate
SystemV service. Patch to websocket_server.rb to make it support
a pidfile. Complete rewrite of the /etc/init.d script for
ubuntu. Support in installation scripts.
parent d7388469
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#! /bin/sh
#!/bin/sh
### BEGIN INIT INFO
# Provides: diaspora-wsd
# Required-Start: $remote_fs $syslog
......@@ -7,21 +7,22 @@
# Default-Stop: 0 1 6
# Short-Description: diaspora websocket daemon
# Description: The diaspora websocket service provider, normally
listening on port 8080
# listening on port 8080
### END INIT INFO
# Author: Alec leamas <leamas.alec@gmail.com>
PATH=/usr/sbin:/usr/bin
PATH=/bin:/sbin:/usr/sbin:/usr/bin
DESC="Websocket server for diaspora clients"
NAME='diaspora-wsd'
DAEMON='/usr/share/diaspora/master/script/websocket_server.rb'
DAEMON_ARGS=""
DAEMON='/usr/local/bin/bundle'
DAEMON_ARGS=' exec ruby ./script/websocket_server.rb'
PIDFILE=/var/run/diaspora/diaspora-wsd.pid
SCRIPTNAME=/etc/init.d/diaspora-wsd
cd /usr/share/diaspora/master
[ -x "$DAEMON" ] || exit 0
vncvi
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
......@@ -40,14 +41,15 @@ do_start()
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
[ -f $PIDFILE ] && {
pid=$( cat $PIDFILE)
name=$( ps -p "$pid" -o comm= 2> /dev/null) || :
[ "$name" = "ruby" ] && return 1
}
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
--chdir $PWD -- $DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
return 0
}
#
......@@ -60,7 +62,8 @@ do_stop()
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE \
--name $NAME --chdir $PWD
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
......@@ -69,7 +72,8 @@ do_stop()
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --chdir $PWD \
--exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
......@@ -85,7 +89,8 @@ do_reload() {
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --chdir $PWD \
--name $NAME
return 0
}
......@@ -98,6 +103,7 @@ case "$1" in
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
......@@ -106,9 +112,11 @@ case "$1" in
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
#reload|force-reload)
#
# If do_reload() is not implemented then leave this commented out
......@@ -118,11 +126,8 @@ case "$1" in
#do_reload
#log_end_msg $?
#;;
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
......@@ -140,9 +145,8 @@ case "$1" in
;;
esac
;;
*)
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
*) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter