From 3e4e09748654ee735ef967ce85fbd147c73e206c Mon Sep 17 00:00:00 2001 From: erg_samowzbudnik Date: Sun, 13 Jun 2021 08:37:25 +0200 Subject: reverting changes --- monitor_unified.py | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) (limited to 'monitor_unified.py') 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') -- cgit v1.2.3-65-gdbad