Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 127 lines (111 sloc) 2.95 KB
#!/bin/sh
#
# tig Startup script for the TIG Server
#
# chkconfig: - 85 15
# description: Twitter IRC Gateway is one of the clients for Twitter.
# processname: tig
# config: /etc/tig/conf/tig.conf
# config: /etc/sysconfig/tig
# pidfile: /var/run/tig.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Start tig in the C locale by default.
TIG_LANG="C"
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set TIG=/usr/sbin/tig.worker in /etc/sysconfig/tig to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
TIG_HOME=/opt/TwitterIrcGateway
tig="./TwitterIrcGatewayCLI"
#tigproc="./TwitterIrcGatewayCLI"
tigproc=TwitterIrcGatewayCLI
prog=TwitterIrcGatewayCLI
pidfile=/var/run/tig.pid
lockfile=/var/lock/subsys/tig
RETVAL=0
OPTIONS="--encoding=utf-8 --bind-address=0.0.0.0"
#TIARRA_HOME=/opt/tiarra
#OUTPUT="|/usr/local/sbin/cronolog /home/logs/tig/%Y/%m/%d/TwitterIrcGateway.log 2>&1"
# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting TwitterIrcGateway: "
cd $TIG_HOME
nohup $tig $OPTIONS 2>&1 > /dev/null &
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
sleep 1 ; [ -f $TIG_HOME/nohup.out ] && rm $TIG_HOME/nohup.out
echo
# sleep 2
# echo -n "Starting tiarra: "
# cd $TIARRA_HOME
# nohup $TIARRA_HOME/tiarra --config=$TIARRA_HOME/tiarra.conf &
# #LANG=$TIG_LANG daemon --pidfile=${pidfile} $tig $OPTIONS $OUTPUT
# #$TIARRA_PATH/tiarra
# RETVAL=$?
# [ $RETVAL -eq 0 ] && touch ${lockfile}
# [ $RETVAL -eq 0 ] && success || failure
# echo
# rm nohup.out
return $RETVAL
}
# When stopping tig a delay of >10 second is required before SIGKILLing the
# tig parent; this gives enough time for the tig parent to SIGKILL any
# errant children.
stop() {
echo -n $"Stopping $prog: "
#kill -9 `/sbin/pidof $tigproc`
killall -9 $prog #; killall -9 tiarra
RETVAL=$?
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
[ $RETVAL -eq 0 ] && success || failure
echo
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$TIG_LANG $tig $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $tig due to configuration syntax error"
else
killproc -p ${pidfile} $tig -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $tig
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 1
esac
exit $RETVAL