Skip to content Skip to sidebar Skip to footer

Check If Twisted Server Launched With Twistd Was Started Successfully

I need a reliable way to check if a Twisted-based server, started via twistd (and a TAC-file), was started successfully. It may fail because some network options are setup wrong. S

Solution 1:

You're explicitly specifying a PID file. twistd will write its PID into that file. You can check the system to see if there is a process with that PID.

You could also re-enable logging with a custom log observer which only logs your startup event and discards all other log messages. Then you can watch the log for the startup event.

Another possibility is to add another server to your application which exposes the internals you mentioned. Then try connecting to that server and looking around to see what you wanted to see (just the fact that the server is running seems like a good indication that the process started up properly, though). If you make it a manhole server then you get the ability to evaluate arbitrary Python code, which lets you inspect any state in the process you want.

You could also just have your application code write out an extra state file that explicitly indicates successful startup. Make sure you delete it before starting the application and you'll have a fine indicator of success vs failure.

Post a Comment for "Check If Twisted Server Launched With Twistd Was Started Successfully"