diff options
author | erg_samowzbudnik <uinarf@autistici.org> | 2021-06-13 08:37:25 +0200 |
---|---|---|
committer | erg_samowzbudnik <uinarf@autistici.org> | 2021-06-13 08:37:25 +0200 |
commit | 3e4e09748654ee735ef967ce85fbd147c73e206c (patch) | |
tree | c2edeebcdd3058df0489686c691d4f731423f41f | |
parent | 0390bc18b498128364b05329c6d84b6c5b505773 (diff) | |
download | RPGH-3e4e09748654ee735ef967ce85fbd147c73e206c.tar.gz RPGH-3e4e09748654ee735ef967ce85fbd147c73e206c.tar.bz2 RPGH-3e4e09748654ee735ef967ce85fbd147c73e206c.zip |
reverting changes
-rw-r--r-- | monitor_unified.py | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/monitor_unified.py b/monitor_unified.py index e1400dc..c61ab3e 100644 --- a/monitor_unified.py +++ b/monitor_unified.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Franek Ćazarewicz-Muradyan" @@ -492,41 +492,6 @@ class Rain(Sensor): # GPIO.add_event_detect(self.pin, GPIO.FALLING, callback=self.read(), # bouncetime=300) -def clean_exit(sig,frame): - #do some other cleanup if you want - os.remove('/var/run/user/1000RPGH_starter.pid') - os.exit(0) - -def start(): - signal.signal(signal.SIGTERM, clean_exit)#from start-stop-daemon - signal.signal(signal.SIGINT, clean_exit)#from ctrl-c - with open('/var/run/user/1000/RPGH_starter.pid', 'x') as pid_file: - pid_file.write(str(os.getpid())) - do_main_loop() - -def main(): - try: action=sys.argv[1] - except IndexError: action='stop' - if action=='start': - start() - elif action=='start_fork': - if os.fork():sys.exit(0) - start() - elif action=='stop': - with open('/var/run/user/1000/RPGH_starter.pid', 'r') as pid_file: - pid=int(pid_file.read()) - os.kill(pid,signal.SIGTERM) - - #optional clean up - try: - child=psutil.Process(pid) - except FileNotFoundError:#psutil didn't find the pid dir in /proc - sys.exit() - try: - child.wait(timeout=10) - except psutil.TimeoutExpired:#we didn't exit/clean up in time - child.kill() - os.remove('/var/run/user/1000/RPGH_starter.pid') if __name__ == '__main__': fq = cfg.getint('hardware_settings', 'read_frequency') |