Re: How-to to stop bearerbox with a script and -parachute

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

just tested it again and it works as expected. Could you please check your
syslog and see whether you have something like this:
bearerbox[12494]: [12494] [0] INFO: Child process with PID (12495) started.
bearerbox[12494]: [12494] [0] INFO: Signal 15 received, forward to child pid
(12495)
bearerbox[12494]: [12494] [0] INFO: Child process exited gracefully, exit...

Please note that init-script must kill parent(parachute) process but not the
child process. Please test it first manually:
$ /path/to/bearerbox --daemonize --parachute /path/to/config
$ ps -ef |grep bearerbox
$ kill (PID from parent process)

If it works you should check init-script. Sorry I'm not a redhat user so
can't help you.

Hillel wrote:

> Hi Kannel Developers,
> 
> We have been using -parachute to start Kannel (using /etc/init.d/kannel)
> to add extra reliability as it was dropping, but then we can't stop Kannel
> using a stop/start script.  It's running using the latest CVS on Centos.
> Without the
> -parachute the script works perfectly and we want to thank Stephane Rosa
> for the great script.
> 
> The reason for the problem is when Kannel starts, with the -parachute, it
> also starts a watcher process to ensure if the child process crashes it
> will restart them automatically. The stop/start script stops the main
> process stored in bearerbox.pid, smsbox.pid and wapbox.pid but does not
> stop the
> -parachute watcher for the bearerbox.  The smsbox does go down after a
> while, but the bearerbox watcher does not stop and allow the bearerbox to
> drop and so you can't re-start Kannel using the script and you need to
> manually kill the pid.
> 
> I'm not sure if this is a bug in the -parachute option.
> 
> Any suggestions appreciated.
> 
> [root@www init.d]# ls /var/run/kannel/
> bearerbox.pid  smsbox.pid  wapbox.pid
> [root@www init.d]# cat /var/run/kannel/bearerbox.pid
> 10073
> [root@www init.d]# cat /var/run/kannel/smsbox.pid
> 10110
> [root@www init.d]# cat /var/run/kannel/wapbox.pid
> 10124
> [root@www init.d]# service kannel status
> bearerbox (pid 10074 10073) is running...
> smsbox (pid 10111 10110) is running...
> wapbox (pid 10125 10124) is running...
> [root@www init.d]# service kannel stop
> Shutting down Mobile Gateway cvs-20070901:                 [  OK  ]
> [root@www init.d]# service kannel status
> bearerbox (pid 10074) is running...
> smsbox (pid 10111 10110) is running...
> wapbox is stopped
> [root@www init.d]# service kannel status
> bearerbox (pid 10074) is running...
> smsbox is stopped
> wapbox is stopped
> 
> Requires manual intervention:
> [root@www init.d]# kill -9 10074
> [root@www init.d]# service kannel status
> bearerbox is stopped
> smsbox is stopped
> wapbox is stopped
> 
> ----------------------------------------------------------------------------
> ------------------------------
> #  This shell script takes care of starting and stopping
> #          the Kannel SMS & WAP gateway
> #          Original version Fabrice Gatille <[email protected]>
> #          Modified by Stephane Rosa ([email protected]) for RedHat9
> # chkconfig: 2345 97 03
> # description: Kannel is an SMS and WAP gateway
> # The actual configurations we use are stored in "/etc/configurations" and
> this is reflected in the script below
> 
> VERSION=`/usr/local/bin/gw-config --version` OPTIONS="--daemonize
> --parachute --user kannel --pid-file /var/run/kannel/"
> KANNELPATH=/usr/local/sbin
> CONF=/etc/kannel.conf
> CONFDIR=/etc/configurations
> 
> # Source function library & networking conf.
> . /etc/init.d/functions
> [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
> 
> # Check that we are root ... so non-root users stop here [ `id -u` = 0 ]
> # ||
> exit 1
> 
> # Various other checks
> [ ${NETWORKING} = "yes" ] || exit 0
> [ -x $KANNELPATH/bearerbox ] || exit 0
> [ -x $KANNELPATH/smsbox ] || exit 0
> [ -x $KANNELPATH/wapbox ] || exit 0
> [ -f $CONF ] || exit 0
> 
> RETVAL=0; RETVAL1=0; RETVAL2=0; RETVAL3=0 prog="Kannel"
> 
> start() {
>    # Check that at least one group is defined for sms
>    # and/or wap to start the bearer. Then start boxes
>    # as needed.
> #   startsms=`egrep -se '^[ \t]*group *= *smsbox' $CONF`
> #   startwap=`egrep -se '^[ \t]*group *= *wapbox' $CONF`
> 
>    startsms=`egrep -hse '^[ \t]*group *= *smsbox' $CONF ${CONFDIR}/*`
>    startwap=`egrep -hse '^[ \t]*group *= *wapbox' $CONF ${CONFDIR}/*`
> 
>   if [ -n "$startsms$startwap" ]; then
>       echo -n "Starting Mobile Gateway Service 1 ($VERSION): "
>       daemon /usr/local/sbin/bearerbox ${OPTIONS}bearerbox.pid -- $CONF
>       RETVAL1=$?
>       echo
>       sleep 15
>    else
>       exit 0
>    fi
> 
>    if [ -n "$startsms" ]; then
>       echo -n "Starting Mobile Gateway Service 2 ($VERSION): "
>       daemon /usr/local/sbin/smsbox ${OPTIONS}smsbox.pid -- $CONF
>       RETVAL2=$?
>       echo
>    fi
> 
>    if [ -n "$startwap" ]; then
>       echo -n "Starting Mobile Gateway Wap service ($VERSION): "
>       daemon /usr/local/sbin/wapbox ${OPTIONS}wapbox.pid -- $CONF
>       RETVAL3=$?
>       echo
>    fi
> 
>    let RETVAL=$REVAL1+$RETVAL2+$RETVAL3
>    if [ $RETVAL -eq 0 ]; then
>       sleep 2
>       touch /var/lock/subsys/gateway
>       cat /var/run/kannel/*.pid > /var/run/kannel.pid
>    fi
>    return $RETVAL
> }
> 
> stop() {
>    echo -n "Shutting down Mobile Gateway $VERSION: "
>    killproc kannel
>    RETVAL=$?
>    echo
> 
> if [ $RETVAL -eq 0 ]; then
>       sleep 2
>       rm -f /var/lock/subsys/gateway
>       rm /var/run/kannel/*.pid
>    fi
>    return $RETVAL
> }
> 
> # See how we were called.
> case "$1" in
>    start)
>       # Start daemons.
>       start
>    ;;
> 
>    stop)
>       # Stop daemons
>       stop
>    ;;
> 
>    restart)
>       # Restart daemons
>       stop
>       sleep 1
>       start
>    ;;
> 
>    status)
>       status bearerbox
>       status smsbox
>       status wapbox
>       exit $?
>    ;;
> 
>    *)
>       echo "Usage: named {start|stop|status|restart}"
>       RETVAL=1
> esac
> 
> exit $RETVAL
> 
> 
> ----------------------------------------------------------------------------
> ------------------------------

-- 
Thanks,
Alex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.