From ac0f0d94697b03676d6fd2d2a0b983bb5aeecefb Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 13 Sep 2016 00:42:21 +0200 Subject: [PATCH] reload on GET /rpc/refresh --- doc/source/debug.rst | 2 ++ larigira/mpc.py | 4 +++- larigira/rpc.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/source/debug.rst b/doc/source/debug.rst index 3d7de95..3c0b906 100644 --- a/doc/source/debug.rst +++ b/doc/source/debug.rst @@ -46,3 +46,5 @@ This is useful if you want to debug the event system, or if you manually changed the data on disk. Please note that the event system will automatically reload the DB from disk when appropriate. However, the WebUI will not, so you might have a misleading ``/db/list`` page; send an ``ALRM`` in this case. + +The same effect can be triggered performing an HTTP ``GET /rpc/refresh``. diff --git a/larigira/mpc.py b/larigira/mpc.py index 4ffecef..952d28b 100644 --- a/larigira/mpc.py +++ b/larigira/mpc.py @@ -134,8 +134,10 @@ class Controller(gevent.Greenlet): except Exception: self.log.exception("Error while adding to queue; " "bad audiogen output?") - elif kind == 'signal' and args[0] == signal.SIGALRM: + elif (kind == 'signal' and args[0] == signal.SIGALRM) or \ + kind == 'refresh': # it's a tick! + self.log.debug("Reload") self.monitor.q.put(dict(kind='forcetick')) gevent.Greenlet.spawn(self.player.check_playlist) else: diff --git a/larigira/rpc.py b/larigira/rpc.py index ce4844d..59a25cc 100644 --- a/larigira/rpc.py +++ b/larigira/rpc.py @@ -38,7 +38,7 @@ def rpc_index(): @rpc.route('/refresh') def rpc_refresh(): - send_to_parent('rpc') + send_to_parent('refresh') return jsonify(dict(status='ok'))