This commit is contained in:
Lerking committed 2020-03-26 21:08:51 +01:00
1 parent 6500a30df8
commit 8fe24f21bb
2 files changed
+10 -9

No files matched your search

-7
View File
@@ -1,8 +1,6 @@
"""Generic linux daemon base class for python 3.x.""" """Generic linux daemon base class for python 3.x."""
import sys, os, time, atexit, signal import sys, os, time, atexit, signal
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class Daemon: class Daemon:
"""A generic daemon class. """A generic daemon class.
@@ -57,11 +55,6 @@ class Daemon:
with open(self.pidfile,'w+') as f: with open(self.pidfile,'w+') as f:
f.write(pid + '\n') f.write(pid + '\n')
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, path='/usr/include', recursive=False)
observer.start()
def delpid(self): def delpid(self):
os.remove(self.pidfile) os.remove(self.pidfile)
+10 -2
View File
@@ -5,8 +5,16 @@ from watchdog.events import FileSystemEventHandler
class h2incDaemon(Daemon): class h2incDaemon(Daemon):
def run(self): def run(self):
while True: event_handler = MyHandler()
time.sleep(1) observer = Observer()
observer.schedule(event_handler, path='/usr/include', recursive=False)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
class MyHandler(FileSystemEventHandler): class MyHandler(FileSystemEventHandler):
def on_modified(self, event): def on_modified(self, event):