run.py 461 B

123456789101112131415161718192021222324252627282930
  1. import os
  2. import grp
  3. import signal
  4. import daemon
  5. import lockfile
  6. from main import (
  7. setup,
  8. main,
  9. cleanup,
  10. reload_config,
  11. )
  12. context = daemon.DaemonContext(
  13. working_directory = '/var/lib/hmmm',
  14. umask = 0o002,
  15. pidfile = lockfile.FileLock('/var/run/hmmm.pid'),
  16. )
  17. context.signal_map = {
  18. signal.SIGTERM: cleanup,
  19. signal.SIGHUP: 'terminate',
  20. signal.SIGUSR1: reload_config
  21. }
  22. initial_program_setup()
  23. with context:
  24. main()