twistd.py 877 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- test-case-name: twisted.test.test_twistd -*-
  2. # Copyright (c) Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4. """
  5. The Twisted Daemon: platform-independent interface.
  6. @author: Christopher Armstrong
  7. """
  8. from twisted.application import app
  9. from twisted.python.runtime import platformType
  10. if platformType == "win32":
  11. from twisted.scripts._twistw import (
  12. ServerOptions,
  13. WindowsApplicationRunner as _SomeApplicationRunner,
  14. )
  15. else:
  16. from twisted.scripts._twistd_unix import ( # type: ignore[assignment]
  17. ServerOptions,
  18. UnixApplicationRunner as _SomeApplicationRunner,
  19. )
  20. def runApp(config):
  21. runner = _SomeApplicationRunner(config)
  22. runner.run()
  23. if runner._exitSignal is not None:
  24. app._exitWithSignal(runner._exitSignal)
  25. def run():
  26. app.run(runApp, ServerOptions)
  27. __all__ = ["run", "runApp"]