OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 | |
3 """ | |
4 Shutdown the device_temp_monitor process launched | |
5 by spawn_device_temp_monitor.py by reading its pid in the file pid_file_path. | |
6 """ | |
7 | |
8 import logging | |
9 import os | |
10 import signal | |
11 import sys | |
12 | |
13 def main(pid_file_path='/tmp/device_monitor_pid'): | |
luqui
2015/09/03 01:10:41
pidfiles usually end in .pid, rather than _pid.
jbudorick
2015/09/03 17:37:31
I'd use argparse for command-line arguments to a s
| |
14 | |
15 try: | |
16 with open(pid_file_path) as pid_file: | |
17 monitor_pid = int(pid_file.readline()) | |
18 | |
19 logging.info('Sending SIGTERM to %d', monitor_pid) | |
20 os.kill(monitor_pid, signal.SIGTERM) | |
21 os.remove(pid_file_path) | |
luqui
2015/09/03 01:10:41
I think it should clean up its own pidfile with a
| |
22 | |
23 except (IOError, OSError): | |
24 logging.exception('Error terminating device monitor') | |
25 | |
26 if __name__ == '__main__': | |
27 sys.exit(main(*sys.argv[1:])) | |
OLD | NEW |