(config)
| 29 | |
| 30 | |
| 31 | def daemon_exec(config): |
| 32 | if 'daemon' in config: |
| 33 | if os.name != 'posix': |
| 34 | raise Exception('daemon mode is only supported on Unix') |
| 35 | command = config['daemon'] |
| 36 | if not command: |
| 37 | command = 'start' |
| 38 | pid_file = config['pid-file'] |
| 39 | log_file = config['log-file'] |
| 40 | if command == 'start': |
| 41 | daemon_start(pid_file, log_file) |
| 42 | elif command == 'stop': |
| 43 | daemon_stop(pid_file) |
| 44 | # always exit after daemon_stop |
| 45 | sys.exit(0) |
| 46 | elif command == 'restart': |
| 47 | daemon_stop(pid_file) |
| 48 | daemon_start(pid_file, log_file) |
| 49 | else: |
| 50 | raise Exception('unsupported daemon command %s' % command) |
| 51 | |
| 52 | |
| 53 | def write_pid_file(pid_file, pid): |
nothing calls this directly
no test coverage detected