[vlma-devel] commit: Ability to restart a streamer. (Adrien Grand )

git version control git at videolan.org
Sun Dec 20 11:56:23 CET 2009


vlma | branch: master | Adrien Grand <jpountz at jpountz.net> | Fri Nov 27 22:59:01 2009 +0100| [3250cb9d0803e706ce3c39a919fa060ef54569b8] | committer: Adrien Grand 

Ability to restart a streamer.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=3250cb9d0803e706ce3c39a919fa060ef54569b8
---

 vlma-watchdog/src/streamer/api.py |    8 ++++----
 vlma-watchdog/src/web.py          |   12 ++++++++++++
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/vlma-watchdog/src/streamer/api.py b/vlma-watchdog/src/streamer/api.py
index 4ff4158..4c514c8 100644
--- a/vlma-watchdog/src/streamer/api.py
+++ b/vlma-watchdog/src/streamer/api.py
@@ -62,7 +62,7 @@ class Streamer:
   def start(self):
     self.__lock.acquire()
     if self.__suspended:
-      self._logger.error("VLC is currently suspended, won't start")
+      self._logger.error("Currently suspended, won't start")
     elif not self.runner is None and self.runner.isAlive():
       self._logger.error("Cannot start streamer %s, another instance is still running.", self.id)
     else:
@@ -133,15 +133,15 @@ class StreamerRunner(threading.Thread):
     self.__lock.release()
     if pid > 0:
       try:
-        if platform_is_windows:
+        if utils.platform_is_windows:
           handle = win32api.OpenProcess(1, False, pid)
           win32api.TerminateProcess(handle, 0)
           win32api.CloseHandle(handle)
         else:
           os.kill(pid, 9)
-      except:
+      except Exception, e:
         #  Process already stopped
-        pass
+        self.__logger.info(e)
     self.join()
     self.start_time = 0
 
diff --git a/vlma-watchdog/src/web.py b/vlma-watchdog/src/web.py
index fa9bf62..eca0861 100644
--- a/vlma-watchdog/src/web.py
+++ b/vlma-watchdog/src/web.py
@@ -34,6 +34,7 @@ class Server(threading.Thread):
       streamers.putChild(streamer.id, s)
       s.putChild("log", StreamerLogsResource(streamer))
       s.putChild("metric", StreamerMetricsResource(streamer))
+      s.putChild("restart", StreamerRestartResource(streamer))
     site = server.Site(root)
     reactor.listenTCP(conf.SERVER_PORT, site)
     self.__logger.info("Starting web server on http://localhost:%d", conf.SERVER_PORT)
@@ -149,3 +150,14 @@ class SystemMetricsResource(AuthenticationRequiredResource):
     prepare_xml_response(request)
     serialization.system_metrics_to_xml(utils.get_system_metrics(), request)
 
+
+class StreamerRestartResource(AuthenticationRequiredResource):
+
+  def __init__(self, streamer):
+    AuthenticationRequiredResource.__init__(self)
+    self.streamer = streamer
+
+  def render_GET_authenticated(self, request):
+    self.streamer.restart()
+    return ""
+



More information about the vlma-devel mailing list