MCPcopy
hub / github.com/shadowsocks/shadowsocks / daemon_exec

Function daemon_exec

shadowsocks/daemon.py:31–50  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

29
30
31def 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
53def write_pid_file(pid_file, pid):

Callers

nothing calls this directly

Calls 2

daemon_startFunction · 0.85
daemon_stopFunction · 0.85

Tested by

no test coverage detected