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.
This commit is contained in:
parent
d738846900
commit
a0c6c175f6
1 changed files with 27 additions and 23 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/sh
|
#!/bin/sh
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: diaspora-wsd
|
# Provides: diaspora-wsd
|
||||||
# Required-Start: $remote_fs $syslog
|
# Required-Start: $remote_fs $syslog
|
||||||
|
|
@ -7,21 +7,22 @@
|
||||||
# Default-Stop: 0 1 6
|
# Default-Stop: 0 1 6
|
||||||
# Short-Description: diaspora websocket daemon
|
# Short-Description: diaspora websocket daemon
|
||||||
# Description: The diaspora websocket service provider, normally
|
# Description: The diaspora websocket service provider, normally
|
||||||
listening on port 8080
|
# listening on port 8080
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
# Author: Alec leamas <leamas.alec@gmail.com>
|
# 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"
|
DESC="Websocket server for diaspora clients"
|
||||||
NAME='diaspora-wsd'
|
NAME='diaspora-wsd'
|
||||||
DAEMON='/usr/share/diaspora/master/script/websocket_server.rb'
|
DAEMON='/usr/local/bin/bundle'
|
||||||
DAEMON_ARGS=""
|
DAEMON_ARGS=' exec ruby ./script/websocket_server.rb'
|
||||||
PIDFILE=/var/run/diaspora/diaspora-wsd.pid
|
PIDFILE=/var/run/diaspora/diaspora-wsd.pid
|
||||||
SCRIPTNAME=/etc/init.d/diaspora-wsd
|
SCRIPTNAME=/etc/init.d/diaspora-wsd
|
||||||
|
|
||||||
|
cd /usr/share/diaspora/master
|
||||||
|
|
||||||
[ -x "$DAEMON" ] || exit 0
|
[ -x "$DAEMON" ] || exit 0
|
||||||
vncvi
|
|
||||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||||
|
|
||||||
# Load the VERBOSE setting and other rcS variables
|
# Load the VERBOSE setting and other rcS variables
|
||||||
|
|
@ -40,14 +41,15 @@ do_start()
|
||||||
# 0 if daemon has been started
|
# 0 if daemon has been started
|
||||||
# 1 if daemon was already running
|
# 1 if daemon was already running
|
||||||
# 2 if daemon could not be started
|
# 2 if daemon could not be started
|
||||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|
[ -f $PIDFILE ] && {
|
||||||
|| return 1
|
pid=$( cat $PIDFILE)
|
||||||
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
|
name=$( ps -p "$pid" -o comm= 2> /dev/null) || :
|
||||||
$DAEMON_ARGS \
|
[ "$name" = "ruby" ] && return 1
|
||||||
|
}
|
||||||
|
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON \
|
||||||
|
--chdir $PWD -- $DAEMON_ARGS \
|
||||||
|| return 2
|
|| return 2
|
||||||
# Add code here, if necessary, that waits for the process to be ready
|
return 0
|
||||||
# to handle requests from services started subsequently which depend
|
|
||||||
# on this one. As a last resort, sleep for some time.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -60,7 +62,8 @@ do_stop()
|
||||||
# 1 if daemon was already stopped
|
# 1 if daemon was already stopped
|
||||||
# 2 if daemon could not be stopped
|
# 2 if daemon could not be stopped
|
||||||
# other if a failure occurred
|
# 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="$?"
|
||||||
[ "$RETVAL" = 2 ] && return 2
|
[ "$RETVAL" = 2 ] && return 2
|
||||||
# Wait for children to finish too if this is a daemon that forks
|
# 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
|
# that waits for the process to drop all resources that could be
|
||||||
# needed by services started subsequently. A last resort is to
|
# needed by services started subsequently. A last resort is to
|
||||||
# sleep for some time.
|
# 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
|
[ "$?" = 2 ] && return 2
|
||||||
# Many daemons don't delete their pidfiles when they exit.
|
# Many daemons don't delete their pidfiles when they exit.
|
||||||
rm -f $PIDFILE
|
rm -f $PIDFILE
|
||||||
|
|
@ -85,7 +89,8 @@ do_reload() {
|
||||||
# restarting (for example, when it is sent a SIGHUP),
|
# restarting (for example, when it is sent a SIGHUP),
|
||||||
# then implement that here.
|
# 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
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,6 +103,7 @@ case "$1" in
|
||||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
stop)
|
stop)
|
||||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||||
do_stop
|
do_stop
|
||||||
|
|
@ -106,9 +112,11 @@ case "$1" in
|
||||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
status)
|
status)
|
||||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||||
;;
|
;;
|
||||||
|
|
||||||
#reload|force-reload)
|
#reload|force-reload)
|
||||||
#
|
#
|
||||||
# If do_reload() is not implemented then leave this commented out
|
# If do_reload() is not implemented then leave this commented out
|
||||||
|
|
@ -118,11 +126,8 @@ case "$1" in
|
||||||
#do_reload
|
#do_reload
|
||||||
#log_end_msg $?
|
#log_end_msg $?
|
||||||
#;;
|
#;;
|
||||||
|
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
#
|
|
||||||
# If the "reload" option is implemented then remove the
|
|
||||||
# 'force-reload' alias
|
|
||||||
#
|
|
||||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||||
do_stop
|
do_stop
|
||||||
case "$?" in
|
case "$?" in
|
||||||
|
|
@ -140,9 +145,8 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
exit 3
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue