diff --git a/README.md b/README.md index 65e718b..f6cb3ff 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ For more details, go check the [API implementation status][api]. * [Transcoding](#transcoding) * [Command line interface](#command-line-interface) * [Quickstart](#quickstart) -* [Scanner daemon](#scanner-daemon) +* [Watching library changes](#watching-library-changes) * [Upgrading](#upgrading) ## Installation @@ -353,12 +353,15 @@ Once you've added a folder, you will need to scan it: You should now be able to enjoy your music with the client of your choice! -## Scanner daemon +## Watching library changes Instead of manually running a scan every time your library changes, you can -run a daemon that will listen to any library change and update the database -accordingly. The daemon is `bin/supysonic-watcher` and can be run as an -*init.d* script. +run a watcher that will listen to any library change and update the database +accordingly. +The watcher is `bin/supysonic-watcher`, it is a non-exiting process and doesn't +print anything to stdout nor stderr. If you want to keep it running in +background, either use the old `nohup` or `screen` methods, or start it as a +simple systemd unit (unit file not included). ## Upgrading diff --git a/bin/supysonic-watcher b/bin/supysonic-watcher index 33d5b7e..f2b0856 100755 --- a/bin/supysonic-watcher +++ b/bin/supysonic-watcher @@ -4,7 +4,7 @@ # This file is part of Supysonic. # # Supysonic is a Python implementation of the Subsonic server API. -# Copyright (C) 2014 Alban 'spl0k' Féron +# Copyright (C) 2014-2017 Alban 'spl0k' Féron # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -19,16 +19,9 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from daemon.runner import DaemonRunner from supysonic.watcher import SupysonicWatcher -watcher = SupysonicWatcher() -watcher.stdin_path = '/dev/null' -watcher.stdout_path = '/dev/tty' -watcher.stderr_path = '/dev/tty' -watcher.pidfile_path = '/tmp/supysonic-watcher.pid' -watcher.pidfile_timeout = 5 - -daemon_runner = DaemonRunner(watcher) -daemon_runner.do_action() +if __name__ == "__main__": + watcher = SupysonicWatcher() + watcher.run() diff --git a/supysonic/watcher.py b/supysonic/watcher.py index d394cd6..1e762df 100644 --- a/supysonic/watcher.py +++ b/supysonic/watcher.py @@ -3,7 +3,7 @@ # This file is part of Supysonic. # # Supysonic is a Python implementation of the Subsonic server API. -# Copyright (C) 2014 Alban 'spl0k' Féron +# Copyright (C) 2014-2017 Alban 'spl0k' Féron # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -20,7 +20,7 @@ import time import logging -from signal import signal, SIGTERM +from signal import signal, SIGTERM, SIGINT from threading import Thread, Condition, Timer from logging.handlers import TimedRotatingFileHandler from watchdog.observers import Observer @@ -241,6 +241,7 @@ class SupysonicWatcher(object): store.close() signal(SIGTERM, self.__terminate) + signal(SIGINT, self.__terminate) self.__running = True queue.start()