Apertium-apy/Sysvinit issues
< Apertium-apy
Jump to navigation
Jump to search
Revision as of 22:36, 13 January 2014 by Firespeaker (talk | contribs) (Created page with "==What we want == An init script for apertium-apy that starts the and stops the daemon, and preferably logs its stdout and stderr. ==The problems== === Logging === Can't...")
Contents
What we want[edit]
An init script for apertium-apy that starts the and stops the daemon, and preferably logs its stdout and stderr.
The problems[edit]
Logging[edit]
Can't figure out how to log stdout or stderr with start-stop-daemon (if it's not possible I'll eat my hat, but I'm just can't find the appropriate information on how to do this)
Subprocesses are not being killed when the parent process is killed[edit]
The parent process pid is kept track of and sent a kill signal. However, the server thread(s) runs in its own pid(s), and these remain running even after the parent thread is killed. We found what we thought is a work-around, but it seems to just make sure the parent thread and other children are killed when one child is killed.
The current init script[edit]
#!/bin/bash # # bot initscript # # Last Updated: Oct 31, 2011 # Modified for Apertium on Jan 11, 2014 # If broken, yell at: firespeaker # ### BEGIN INIT INFO # Provides: apy # Required-Start: $network # Required-Stop: $network # Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Apertium APY, Apertium API in Python ### END INIT INFO SERVLET="servlet.py" EXEC="/traductors/apertium-apy/" ARGS="-l tools/turkic.db ../pairs" USER="www-data" start_apy() { start-stop-daemon -S -c $USER -p /var/run/$SERVLET.pid -m -d $EXEC -b -x $EXEC/$SERVLET -- $ARGS SUCCESS=$? if [ $SUCCESS -gt 0 ]; then echo "ERROR: Couldn't start $SERVLET" fi return $SUCCESS } stop_apy() { start-stop-daemon -K -p /var/run/$SERVLET.pid SUCCESS=$? if [ $SUCCESS -gt 0 ]; then echo "ERROR: Couldn't stop $SERVLET" fi return $SUCCESS } case "$1" in start) echo "Starting $SERVLET" start_apy ;; stop) echo "Stopping $SERVLET" stop_apy ;; restart) echo "Restarting $SERVLET" stop_apy if [ $? -gt 0 ]; then exit -1 fi start_apy ;; force-reload) echo "Restarting $SERVLET" stop_apy if [ $? -gt 0 ]; then exit -1 fi start_apy ;; status) if [ -e /var/run/$SERVLET.pid ]; then exit 0 fi exit 3 ;; *) echo "Usage: /etc/init.d/$SERVLET {start, stop, restart, force-reload, status}" exit 1 ;; esac exit 0