[Twisted-Python] twistd and init.d

gary clark burslem2001 at yahoo.com
Wed Apr 21 07:15:54 MDT 2010


My understanding is the twistd will have a default log twistd.log. 
 
Thanks,
Garyc

--- On Wed, 4/21/10, Don Schoeman <don at delphexonline.com> wrote:


From: Don Schoeman <don at delphexonline.com>
Subject: Re: [Twisted-Python] twistd and init.d
To: "Twisted general discussion" <twisted-python at twistedmatrix.com>
Date: Wednesday, April 21, 2010, 7:54 AM


Sorry, I mean't to say I will use the full path to twistd (i.e. /usr/bin/twistd) and see if that works.

Don Schoeman wrote: 
Thanks for the tips guys,

Maartin, I have a feeling that you may be correct. I'm going to see if I can't set the python path within the script.

Tim, the only reason I can see anything in  /var/logs/messages is because I use the "logger" tool to log those messages directly from the bash shell script. See the script below.

Kind Regards,
Don


Don Schoeman wrote: 
Hi guys,

My application is being executed using twistd as per documentation. All is working fine but I need to have the service start automatically at boot time.

So as a test I've created a script in /etc/init.d/ which looks like this:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          ghserver
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop GHServer server
### END INIT INFO

logger "GHServer: Start script executed"
GH_SERVER_PATH="/home/myname/Python/ghserver"
export PYTHONPATH="$GH_SERVER_PATH:$PYTHONPATH"

case "$1" in
  start)
    logger "GHServer: Starting"
    echo "Starting GHServer..."
    twistd -y "$GH_SERVER_PATH/ghserverapp.py" -l "$GH_SERVER_PATH/ghserver.log" --pidfile "$GH_SERVER_PATH/twistd.pid"
    ;;
  stop)
    logger "GHServer: Stopping"
    echo "Stopping GHServer..."
    kill `cat $GH_SERVER_PATH/twistd.pid`
    ;;
  *)
    logger "GHServer: Invalid usage"
    echo "Usage: /etc/init.d/ghserver {start|stop}"
    exit 1
    ;;
esac

exit 0


This works fine when running /etc/init.d/ghserver start and /etc/init.d/ghserver stop. The script also run when I boot since the logger actually logs the "GHServer: Starting" text to the /var/log/messages file. However, my service actually does not start. There is no pid to be found anywhere, there are no error logs anywhere, just nothing. I might be doing something wrong here but is there someone who's gone through this process and can provide some samples how they did it? Any help will be greatly appreciated.

Kind Regards,
Don



_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
  
_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
  
-----Inline Attachment Follows-----


_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20100421/4ebbfca5/attachment.html>


More information about the Twisted-Python mailing list