-
Notifications
You must be signed in to change notification settings - Fork 30
/
run.py
55 lines (47 loc) · 1.43 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#coding:utf-8
import time
import gevent
from gevent.monkey import patch_all
patch_all()
from gevent.pywsgi import WSGIServer
import locale
import argparse
import logging
import socket
import urllib
import urllib2
from logging import getLogger
from flask import Flask
import zerorpc
from psdash import __version__
from psdash.node import LocalNode, RemoteNode
from psdash.run import PsDashRunner
from datetime import datetime, timedelta
logger = getLogger('psdash.run')
class DashRunner(PsDashRunner):
def _create_app(self, config=None):
app = Flask(__name__)
#app.debug=True
from web import fromtimestamp
app.add_template_filter(fromtimestamp)
app.config.PSDASH_REGISTER_INTERVAL = 10
app.psdash = self
app.config.from_envvar('PSDASH_CONFIG', silent=True)
if config and isinstance(config, dict):
app.config.update(config)
self._load_allowed_remote_addresses(app)
# If the secret key is not read from the config just set it to something.
if not app.secret_key:
app.secret_key = 'whatisthissourcery'
from web import webapp
prefix = app.config.get('PSDASH_URL_PREFIX')
if prefix:
prefix = '/' + prefix.strip('/')
webapp.url_prefix = prefix
app.register_blueprint(webapp)
return app
def main():
r=DashRunner.create_from_cli_args()
r.run()
if __name__ == '__main__':
main()