Permalink
Browse files

HH-26775 little frontik features

  • Loading branch information...
1 parent b0ed183 commit 3b8cf00d794687530216bfcd542efba813a6f8b6 @katraev katraev committed May 30, 2012
Showing with 16 additions and 2 deletions.
  1. +10 −0 frontik/app.py
  2. +1 −0 frontik/handler.py
  3. +2 −1 frontik/jobs.py
  4. +3 −1 frontik/options.py
View
@@ -3,6 +3,7 @@
import os.path
import sys
import re
+import time
import lxml.etree as etree
import tornado.autoreload
@@ -54,6 +55,15 @@ def get(self):
self.write('pages served: %s\n' % (handler.stats.page_count,))
self.write('http reqs made: %s\n' % (handler.stats.http_reqs_count,))
self.write('http reqs got: %s bytes\n' % (handler.stats.http_reqs_size_sum,))
+ cur_uptime = time.time() - handler.stats.start_time
+ if cur_uptime < 60:
+ res = 'uptime for : %d seconds\n' % ((cur_uptime),)
+ elif cur_uptime < 3600:
+ res = 'uptime for : %d minutes\n' % ((cur_uptime/60),)
+ else:
+ res = 'uptime for : %d hours and %d minutes \n' % ((cur_uptime/3600), (cur_uptime % 3600)/60)
+
+ self.write(res)
class StopHandler(tornado.web.RequestHandler):
View
@@ -77,6 +77,7 @@ def __init__(self):
self.page_count = 0
self.http_reqs_count = 0
self.http_reqs_size_sum = 0
+ self.start_time = time.time()
def next_request_id(self):
self.page_count += 1
View
@@ -18,7 +18,8 @@ def queue_worker(queue):
try:
(prio, (func, cb, exception_cb)) = queue.get(timeout=10)
except Queue.Empty:
- log.warn('No job in 10 secs')
+ if tornado.options.options.warn_no_jobs:
+ log.warn('No job in 10 secs')
continue
except Exception, e:
log.exception('Cannot get new job')
View
@@ -22,4 +22,6 @@
tornado.options.define('graylog', False, bool)
tornado.options.define('graylog_host', "localhost", str)
-tornado.options.define('graylog_port', 12201, int)
+tornado.options.define('graylog_port', 12201, int)
+
+tornado.options.define('warn_no_jobs', True, bool)

0 comments on commit 3b8cf00

Please sign in to comment.