Add kill by PID for the python script
This commit is contained in:
parent
0e3a71b322
commit
62b136724e
|
@ -7237,6 +7237,7 @@
|
|||
"append": "",
|
||||
"useSpawn": "true",
|
||||
"timer": "",
|
||||
"winHide": false,
|
||||
"oldrc": false,
|
||||
"name": "",
|
||||
"x": 1090,
|
||||
|
@ -7305,11 +7306,12 @@
|
|||
"id": "ed7503f3.d95a48",
|
||||
"type": "exec",
|
||||
"z": "9daf9e2b.019fc",
|
||||
"command": "sudo killall -15 python3",
|
||||
"command": "sudo kill -15 `cat /tmp/pscope_pid`",
|
||||
"addpay": false,
|
||||
"append": "",
|
||||
"useSpawn": "false",
|
||||
"timer": "",
|
||||
"winHide": false,
|
||||
"oldrc": false,
|
||||
"name": "Python soft kill",
|
||||
"x": 740,
|
||||
|
|
|
@ -78,6 +78,10 @@ if __name__ == "__main__":
|
|||
signal.signal(signal.SIGINT, handler_stop_signals)
|
||||
signal.signal(signal.SIGTERM, handler_stop_signals)
|
||||
|
||||
# Create script PID file, so it's easy to kill the main process without ravaging all python script in the OS
|
||||
with open('/tmp/pscope_pid', 'w') as f:
|
||||
f.write(str(os.getpid()))
|
||||
|
||||
# check if gpu_mem configuration is at least 256Meg, otherwise the camera will not run properly
|
||||
with open("/boot/config.txt", "r") as config_file:
|
||||
for i, line in enumerate(config_file):
|
||||
|
@ -190,4 +194,8 @@ if __name__ == "__main__":
|
|||
# module_thread.close()
|
||||
|
||||
display.stop()
|
||||
|
||||
# Cleanup pid file
|
||||
os.remove('/tmp/pscope_pid')
|
||||
|
||||
logger.info("Bye")
|
||||
|
|
Loading…
Reference in a new issue