An ApplicationRunner which does Unix-specific things, like fork, shed privileges, and maintain a PID file.

Method preApplication Do pre-application-creation setup.
Method postApplication To be called after the application is created: start the application and run the reactor. After the reactor stops, clean up PID files and such.
Method removePID Remove the specified PID file, if possible. Errors are logged, not raised.
Method setupEnvironment Set the filesystem root, the working directory, and daemonize.
Method daemonize Daemonizes the application on Unix. This is done by the usual double forking approach.
Method shedPrivileges Change the UID and GID or the EUID and EGID of this process.
Method startApplication Configure global process state based on the given application and run the application.
Method _waitForStart Wait for the daemonization success.

Inherited from ApplicationRunner:

Instance Variable config The config object, which provides a dict-like interface.
Instance Variable application Available in postApplication, but not preApplication. This is the application object.
Instance Variable profilerFactory Factory for creating a profiler object, able to profile the application if options are set accordingly.
Instance Variable profiler Instance provided by profilerFactory.
Instance Variable loggerFactory Factory for creating object responsible for logging.
Instance Variable logger Instance provided by loggerFactory.
Method __init__ Undocumented
Method run Run the application.
Method startReactor Run the reactor with the given configuration. Subclasses should probably call this from postApplication.
Method createOrGetApplication Create or load an Application based on the parameters found in the given ServerOptions instance.
def preApplication(self): (source)

Do pre-application-creation setup.

def postApplication(self): (source)

To be called after the application is created: start the application and run the reactor. After the reactor stops, clean up PID files and such.

def removePID(self, pidfile): (source)

Remove the specified PID file, if possible. Errors are logged, not raised.

ParameterspidfileThe path to the PID tracking file. (type: str)
def setupEnvironment(self, chroot, rundir, nodaemon, umask, pidfile): (source)

Set the filesystem root, the working directory, and daemonize.

ParameterschrootIf not None, a path to use as the filesystem root (using os.chroot). (type: str or NoneType)
rundirThe path to set as the working directory. (type: str)
nodaemonA flag which, if set, indicates that daemonization should not be done. (type: bool)
umaskThe value to which to change the process umask. (type: int or NoneType)
pidfileIf not None, the path to a file into which to put the PID of this process. (type: str or NoneType)
def daemonize(self, reactor): (source)

Daemonizes the application on Unix. This is done by the usual double forking approach.

ParametersreactorThe reactor in use. If it provides IReactorDaemonize, its daemonization-related callbacks will be invoked.
ReturnsA writable pipe to be used to report errors. (type: int)
See Alsohttp://code.activestate.com/recipes/278731/
W. Richard Stevens, "Advanced Programming in the Unix Environment", 1992, Addison-Wesley, ISBN 0-201-56317-7
def _waitForStart(self, readPipe): (source)

Wait for the daemonization success.

ParametersreadPipefile descriptor to read start information from. (type: int)
Returnscode to be passed to os._exit: 0 for success, 1 for error. (type: int)
def shedPrivileges(self, euid, uid, gid): (source)

Change the UID and GID or the EUID and EGID of this process.

ParameterseuidA flag which, if set, indicates that only the effective UID and GID should be set. (type: bool)
uidIf not None, the UID to which to switch. (type: int or NoneType)
gidIf not None, the GID to which to switch. (type: int or NoneType)
def startApplication(self, application): (source)

Configure global process state based on the given application and run the application.

ParametersapplicationAn object which can be adapted to service.IProcess and service.IService.
API Documentation for Twisted, generated by pydoctor at 2016-04-04 15:02:49.