diff --git a/circusweb/circushttpd.py b/circusweb/circushttpd.py index 24d354b..9e6e59a 100644 --- a/circusweb/circushttpd.py +++ b/circusweb/circushttpd.py @@ -6,6 +6,7 @@ import sys import json from base64 import b64encode, b64decode +from datetime import datetime from zmq.eventloop import ioloop import socket @@ -98,6 +99,7 @@ def render_template(self, template_path, **data): server = '%s://%s/' % (self.request.protocol, self.request.host) namespace.update({'controller': get_controller(), 'version': __version__, + 'now': datetime.now, 'b64encode': b64encode, 'dumps': json.dumps, 'session': self.session, 'messages': messages, @@ -242,7 +244,6 @@ def get(self, endpoint, name): redirect_url=self.reverse_url('index')) self.redirect(url) - class KillProcessHandler(BaseHandler): @require_logged_user @@ -333,6 +334,34 @@ def get(self, endpoint): self.redirect(url) +class StartAllHandler(BaseHandler): + + @require_logged_user + @tornado.web.asynchronous + @gen.coroutine + def get(self, endpoint): + url = yield self.run_command(command='start_all', + message='starting all watchers', + endpoint=b64decode(endpoint), + args=[], + redirect_url=self.reverse_url('index')) + self.redirect(url) + + +class StopAllHandler(BaseHandler): + + @require_logged_user + @tornado.web.asynchronous + @gen.coroutine + def get(self, endpoint): + url = yield self.run_command(command='stop_all', + message='stopping all watchers', + endpoint=b64decode(endpoint), + args=[], + redirect_url=self.reverse_url('index')) + self.redirect(url) + + class Application(tornado.web.Application): def __init__(self): @@ -349,6 +378,10 @@ def __init__(self): WatcherAddHandler, name="add_watcher"), URLSpec(r'/([^/]+)/watcher/([^/]+)/', WatcherHandler, name="watcher"), + URLSpec(r'/([^/]+)/start_all/', + StartAllHandler, name="start_all"), + URLSpec(r'/([^/]+)/stop_all/', + StopAllHandler, name="stop_all"), URLSpec(r'/([^/]+)/watcher/([^/]+)/switch_status/', WatcherSwitchStatusHandler, name="switch_status"), URLSpec(r'/([^/]+)/watcher/([^/]+)/process/kill/([^/]+)/', diff --git a/circusweb/controller.py b/circusweb/controller.py index 37a5973..c184925 100644 --- a/circusweb/controller.py +++ b/circusweb/controller.py @@ -143,6 +143,22 @@ def switch_status(self, name, endpoint): raise gen.Return(res) + @gen.coroutine + def start_all(self, endpoint): + client = self.get_client(endpoint) + msg = cmds['start'].make_message(name='*') + res = yield gen.Task(client.call, msg) + + raise gen.Return(res) + + @gen.coroutine + def stop_all(self, endpoint): + client = self.get_client(endpoint) + msg = cmds['stop'].make_message(name='*') + res = yield gen.Task(client.call, msg) + + raise gen.Return(res) + @gen.coroutine def reloadconfig(self, endpoint): client = self.get_client(endpoint) diff --git a/circusweb/media/circus.css b/circusweb/media/circus.css index 9a41cf9..f52398a 100644 --- a/circusweb/media/circus.css +++ b/circusweb/media/circus.css @@ -285,7 +285,7 @@ footer { box-shadow: 0 0 5px #757575; } -.reloadconfig, .add_watcher, .add_endpoint { +.reloadconfig, .add_watcher, .add_endpoint, .watchers_start_all, .watchers_stop_all { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; @@ -312,6 +312,10 @@ footer { text-decoration: none; } +.watchers_start_all, .watchers_stop_all { + width: auto; +} + .add_watcher:active { -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.1); -moz-box-shadow: inset 0 1px 2px rgba(0,0,0,.1); diff --git a/circusweb/templates/base.html b/circusweb/templates/base.html index 0e57031..f7904ea 100644 --- a/circusweb/templates/base.html +++ b/circusweb/templates/base.html @@ -2,7 +2,7 @@
- +