[Twisted-Python] twistd and init.d

Tim Allen screwtape at froup.com
Wed Apr 21 08:16:56 EDT 2010

On Wed, Apr 21, 2010 at 01:38:09PM +0200, Don Schoeman wrote:
>    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?

I haven't written an init-script for twistd myself, I just use the one
auto-generated by tap2rpm. You can compare your script to the template
tap2rpm uses and see if that gives you any clues:

It surprises me that you say you can tell that the script runs at boot
because you can see it in /var/log/messages - although most Linux
distros hide the boot-script messages by default, they usually provide
a way to display them for debugging purposes such as these (different
distributions use different actions to trigger boot messages; if you
can't find instructions for your distribution online, you might try
hitting Escape a few times at different parts of the boot sequence).

Finally, in my limited experience of diagnosing scripts that work from
an interactive shell but not at boot time, you might want to look for
code that uses environment variables. $EMPLOYER once had some scripts
that got some particular setting from an environment variable that was
only set by interactive shells - so if you ssh'd to the machine and ran
the code, it'd be fine, but it crashed when run at bootup.

CentOS (and perhaps other Linux distributions) has a tool called
/sbin/service. If you run "/sbin/service ghserver start" rather than
"/etc/init.d/ghserver start", /sbin/service will start the service in
a clean, boot-like environment and you might get more debugging clues
that way.

More information about the Twisted-Python mailing list