Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`scripts`.`_twistd_unix`.`UnixApplicationRunner``

class documentation

`class UnixApplicationRunner(app.ApplicationRunner): (source)`

Constructor: `UnixApplicationRunner(config)`

View In Hierarchy

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

Method | `daemonize` | Daemonizes the application on Unix. This is done by the usual double forking approach.
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 | `preApplication` | Do pre-application-creation setup.
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 | `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.
Instance Variable | `oldstderr` | Undocumented
Instance Variable | `oldstdout` | Undocumented
Method | `_formatChildException` | Format the `exception` in preparation for writing to the status pipe. This does the right thing on Python 2 if the exception's message is Unicode, and in all cases limits the length of the message afte* encoding to 100 bytes.
Method | `_waitForStart` | Wait for the daemonization success.

Inherited from `ApplicationRunner`:

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

def daemonize(self, reactor): (source)

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

Parameters
reactor | The reactor in use. If it provides `IReactorDaemonize`, its daemonization-related callbacks will be invoked.
Returns
`int` | A writable pipe to be used to report errors.
See Also
http://code.activestate.com/recipes/278731/
W. Richard Stevens, "Advanced Programming in the Unix Environment", 1992, Addison-Wesley, ISBN 0-201-56317-7

def postApplication(self): (source)
overrides `twisted.application.app.ApplicationRunner.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.

def preApplication(self): (source)
overrides `twisted.application.app.ApplicationRunner.preApplication`

Do pre-application-creation setup.

def removePID(self, pidfile): (source)

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

Parameters
pidfile:`str` | The path to the PID tracking file.

def setupEnvironment(self, chroot, rundir, nodaemon, umask, pidfile): (source)

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

Parameters
chroot:`str` or `None` | If not None, a path to use as the filesystem root (using `os.chroot`).
rundir:`str` | The path to set as the working directory.
nodaemon:`bool` | A flag which, if set, indicates that daemonization should not be done.
umask:`int` or `None` | The value to which to change the process umask.
pidfile:`str` or `None` | If not `None`, the path to a file into which to put the PID of this process.

def shedPrivileges(self, euid, uid, gid): (source)

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

Parameters
euid:`bool` | A flag which, if set, indicates that only the effective UID and GID should be set.
uid:`int` or `None` | If not `None`, the UID to which to switch.
gid:`int` or `None` | If not `None`, the GID to which to switch.

def startApplication(self, application): (source)

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

Parameters
application | An object which can be adapted to `service.IProcess` and `service.IService`.

oldstderr = (source)

Undocumented

oldstdout = (source)

Undocumented

def _formatChildException(self, exception): (source)

Format the `exception` in preparation for writing to the status pipe. This does the right thing on Python 2 if the exception's message is Unicode, and in all cases limits the length of the message afte* encoding to 100 bytes.

This means the returned message may be truncated in the middle of a unicode escape.

Parameters
exception:`Exception` | The exception to format.
Returns
`bytes` | The formatted message, suitable for writing to the status pipe.

def _waitForStart(self, readPipe: `int`) -> `int`: (source)

Wait for the daemonization success.

Parameters
readPipe:`int` | file descriptor to read start information from.
Returns
`int` | code to be passed to `os._exit`: 0 for success, 1 for error.