diff --git a/.todo.swp b/.todo.swp new file mode 100644 index 0000000..e53906f Binary files /dev/null and b/.todo.swp differ 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