From e970dce5d0d5a592b50bbfd88a4b814095b7a35d Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Thu, 5 Nov 2020 22:50:52 +0100 Subject: [PATCH] fix init scripts and error in log message --- .todo.swp | Bin 0 -> 12288 bytes pyinotifyd/misc/openrc/pyinotifyd.confd | 5 ++++- pyinotifyd/misc/openrc/pyinotifyd.initd | 10 +++++++++- pyinotifyd/misc/systemd/pyinotifyd.service | 1 + pyinotifyd/scheduler.py | 2 +- pyinotifyd/watch.py | 10 +--------- todo | 0 7 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 .todo.swp create mode 100644 todo diff --git a/.todo.swp b/.todo.swp new file mode 100644 index 0000000000000000000000000000000000000000..e53906f7c92e6cdad933c0c0933389ad25c9bdb0 GIT binary patch literal 12288 zcmeI%!Aiq07zgmLf=6}e3q(C{ogK1W^eA}f#W}&#mMv);3{6>6WETa&H}MI)dJ!MM zlkc$CFddx-Vbg2JKk)I9=F8XScMBc2Z!SaDYX#&+gXnqpWjH$h^xkh9WNc!}$A67U zl1I622HozW%gXYHvY{`y<$kQJpUqTitcqsBw?_QyO)Fbt0Rj+MCs5d^+1nX(f|GVx zc6@Zm4)zD@c3=$x5P$##AOHafKmY;|*f0T`dGzScv{jvJyUO0LTuqT6009U<00Izz z00bZa0SG_<0uZR702f40dql4;%K!h%`~Td{zg&E{cyqB>ui^Rd$q;}51Rwwb2tWV= z5P$##AOL}S3iOl03Ui;*mDI*v->-Ro*PkR(6k1MO+QbwV+Nw-Twk*x*LTMTDl*e+) K&d%9SJ$(Zq1V2mw literal 0 HcmV?d00001 diff --git a/pyinotifyd/misc/openrc/pyinotifyd.confd b/pyinotifyd/misc/openrc/pyinotifyd.confd index ac23c46..d7c7340 100644 --- a/pyinotifyd/misc/openrc/pyinotifyd.confd +++ b/pyinotifyd/misc/openrc/pyinotifyd.confd @@ -4,5 +4,8 @@ # USER="daemon" # USER="daemon:nobody" -# Optional parameters for pymodmilter +# Set the shutdown timeout +# SHUTDOWN_TIMEOUT=300 + +# Optional command line options # PYINOTIFYD_OPTS="" diff --git a/pyinotifyd/misc/openrc/pyinotifyd.initd b/pyinotifyd/misc/openrc/pyinotifyd.initd index 42dc372..cb488b3 100755 --- a/pyinotifyd/misc/openrc/pyinotifyd.initd +++ b/pyinotifyd/misc/openrc/pyinotifyd.initd @@ -2,14 +2,16 @@ user=${USER:-root} pyinotifyd_opts="${PYINOTIFYD_OPTS:-}" +shutdown_timeout="${SHUTDOWN_TIMEOUT:-300}" pidfile="/run/${RC_SVCNAME}.pid" command="/usr/bin/pyinotifyd" command_args="${pyinotifyd_opts}" command_background=true start_stop_daemon_args="--user ${user}" +retry="SIGTERM/${shutdown_timeout}" -extra_commands="configtest" +extra_commands="configtest reload" depend() { need net @@ -44,3 +46,9 @@ stop_pre() { checkconfig || return $? fi } + +reload() { + ebegin "Reloading ${SVCNAME}" + start-stop-daemon --signal HUP --pidfile "${pidfile}" + eend $? +} diff --git a/pyinotifyd/misc/systemd/pyinotifyd.service b/pyinotifyd/misc/systemd/pyinotifyd.service index 3e6f542..ccbbe8f 100644 --- a/pyinotifyd/misc/systemd/pyinotifyd.service +++ b/pyinotifyd/misc/systemd/pyinotifyd.service @@ -5,6 +5,7 @@ After=fs.target [Service] Type=simple ExecStart=/usr/bin/pyinotifyd +ExecReload=/bin/kill -HUP $MAINPID TimeoutStopSec=300 [Install] diff --git a/pyinotifyd/scheduler.py b/pyinotifyd/scheduler.py index 3538809..1898479 100755 --- a/pyinotifyd/scheduler.py +++ b/pyinotifyd/scheduler.py @@ -57,7 +57,7 @@ class _Task: self.cancel() self.start() - def task_id(): + def task_id(self): return self._task_id diff --git a/pyinotifyd/watch.py b/pyinotifyd/watch.py index ff99149..40ccf91 100755 --- a/pyinotifyd/watch.py +++ b/pyinotifyd/watch.py @@ -100,16 +100,8 @@ class Watch: def event_notifier(self, wm, loop=asyncio.get_event_loop()): handler = pyinotify.ProcessEvent() - mask = False - for flag, values in self.event_map.items(): - setattr(handler, f"process_{flag}", _TaskList(values).execute) - if mask: - mask = mask | EventMap.flags[flag] - else: - mask = EventMap.flags[flag] - wm.add_watch( - self.path, mask, rec=self.rec, auto_add=self.auto_add, + self.path, pyinotify.ALL_EVENTS, rec=self.rec, auto_add=self.auto_add, do_glob=True) return pyinotify.AsyncioNotifier(wm, loop, default_proc_fun=handler) diff --git a/todo b/todo new file mode 100644 index 0000000..e69de29