Skip to content

Commit

Permalink
Logging part of configuration and javascript depends hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
philberty committed Jun 6, 2014
1 parent ac9583b commit 132f8fd
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 31 deletions.
1 change: 1 addition & 0 deletions WatchyServer/BackendUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def run (self):
for i in self.backends:
i.consume (data)
except Queue.Empty:
# sleep to stop spamming the process
time.sleep (1)
except:
ServerUtil.error ("%s" % traceback.format_exc ())
Expand Down
3 changes: 1 addition & 2 deletions WatchyServer/StatsServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ def statics (path):

class WatchyDServer:
def __init__ (self, cacheLimit, backends, wbind='localhost', wport=8080,
ubind='localhost', uport=8081, debug=False):
ubind='localhost', uport=8081):
self.web_bind = wbind
self.web_port = wport
self.debug = debug
self.udp_server = UDPStatsServer (host=ubind, port=uport,
climit=cacheLimit, backends=backends)

Expand Down
7 changes: 7 additions & 0 deletions WatchyServer/static/css/bootstrap.min.css

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions WatchyServer/static/js/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions WatchyServer/static/js/jquery.flot.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions WatchyServer/static/js/jquery.flot.time.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions WatchyServer/static/js/jquery.min.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions WatchyServer/templates/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stats Node {{ node }}</title>

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="/deps/css/bootstrap.min.css" rel="stylesheet">
<link href="/deps/css/index.css" rel="stylesheet" type="text/css">
<link href="/deps/css/graph.css" rel="stylesheet" type="text/css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.time.min.js"></script>

<script src="/deps/js/jquery.min.js"></script>
<script src="/deps/js/bootstrap.min.js"></script>
<script src="/deps/js/jquery.flot.min.js"></script>
<script src="/deps/js/jquery.flot.time.min.js"></script>

<script type="text/javascript">
$(function () {
Expand Down
9 changes: 4 additions & 5 deletions WatchyServer/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Watchy Dashboard</title>

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="deps/css/index.css" rel="stylesheet" type="text/css">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link href="/deps/css/bootstrap.min.css" rel="stylesheet">
<link href="/deps/css/index.css" rel="stylesheet" type="text/css">
<script src="/deps/js/jquery.min.js"></script>
<script src="/deps/js/bootstrap.min.js"></script>

<script type="text/javascript">
$(function() {
Expand Down
7 changes: 4 additions & 3 deletions WatchyServer/templates/logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stats Node {{ node }}</title>

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="/deps/css/bootstrap.min.css" rel="stylesheet">
<link href="/deps/css/index.css" rel="stylesheet" type="text/css">
<link href="/deps/css/log.css" rel="stylesheet" type="text/css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

<script src="/deps/js/jquery.min.js"></script>
<script src="/deps/js/bootstrap.min.js"></script>

<script type="text/javascript">
$(function () {
Expand Down
22 changes: 22 additions & 0 deletions etc/watchy/example-watchy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,25 @@ uri = amqp://guest:guest@localhost:5672/%2F
[mongo]
type = mongodb
uri = mongodb://localhost:27017

[loggers]
keys=root

[handlers]
keys=consoleHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[formatter_simpleFormatter]
format=WATCHY %(levelname)s - %(message)s
19 changes: 3 additions & 16 deletions watchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import optparse
import traceback
import logging.config

from WatchyServer import ServerUtil
from WatchyServer import StatsServer
Expand All @@ -26,10 +27,6 @@ def serverMain ():
help="Config file location", default=None)
parser.add_option ("-F", "--fork", dest="fork", action="store_true",
help="Fork as daemon", default=False)
parser.add_option ("-N", "--name", dest="name",
help="Logging name", default="WATCHY")
parser.add_option ("-d", "--debug", dest="debug", action="store_true",
help="Verbose Debugging on of off", default=False)
(options, args) = parser.parse_args ()
if options.version is True:
printVersion ()
Expand Down Expand Up @@ -61,6 +58,7 @@ def serverMain ():
except BackendUtil.BackendInitException:
print >> sys.stderr, "Error intilizing backend %s" % sys.exc_info ()[1]
sys.exit (-1)
logging.config.fileConfig (options.config)
if options.fork is True:
pid = os.fork ()
if pid == -1:
Expand All @@ -72,19 +70,8 @@ def serverMain ():
else:
print pid
sys.exit (0)
form = '[' + options.name + '] %(levelname)s %(message)s'
level = logging.DEBUG if options.debug else logging.INFO
logging.basicConfig (filename = options.logfile, level = level, format = form,
datefmt = '%m/%d/%Y %I:%M:%S', filemode = 'w+')
if options.debug is True:
rootLogger = logging.getLogger ()
consoleHandler = logging.StreamHandler ()
formatter = logging.Formatter (form)
consoleHandler.setFormatter (formatter)
rootLogger.addHandler (consoleHandler)
StatsServer.WatchyDServer (limit, backends, wbind=rbind, wport=rport,
ubind=abind, uport=aport,
debug=options.debug).listen ()
ubind=abind, uport=aport).listen ()

if __name__ == "__main__":
serverMain ()

0 comments on commit 132f8fd

Please sign in to comment.