コード例 #1
0
from search import SearchHandler
from histogram import HistogramHandler
from hint import HintHandler
from stats import StatsHandler
from sensorsdb import SensorsDBHandler
from signal import signal, SIGTERM, SIGQUIT
from configuration import env
from nginx import NGINX

sthost = env["STHOST"]
dbhost = env["DBHOST"]
webrtchost = env.get("WEBRTCHOST", "http://127.0.0.1:8888")
tornado1 = None
nginx1 = NGINX(upstreams=[
    ("storage-service", sthost.partition("://")[2]),
    ("database-service", dbhost.partition("://")[2]),
    ("webrtc-service", webrtchost.partition("://")[2]),
])


def quit_service(signum, frame):
    if tornado1: tornado1.add_callback(tornado1.stop)
    nginx1.stop()


app = web.Application([
    (r'/api/search', SearchHandler),
    (r'/api/histogram', HistogramHandler),
    (r'/api/hint', HintHandler),
    (r'/api/stats', StatsHandler),
    (r'/api/sensorsdb', SensorsDBHandler),
コード例 #2
0
#!/usr/bin/python3

from tornado import ioloop, web
from tornado.options import define, options, parse_command_line
from workload import WorkloadHandler
from upload import UploadHandler
from thumbnail import ThumbnailHandler
from subprocess import Popen
from signal import signal, SIGTERM, SIGQUIT
from nginx import NGINX

tornado1=None
nginx1=NGINX()
cleanup1=None

def quit_service(signum, frame):
    if tornado1: tornado1.add_callback(tornado1.stop)
    if cleanup1: cleanup1.send_signal(SIGTERM)
    nginx1.stop()

app = web.Application([
    (r'/api/upload',UploadHandler),
    (r'/api/thumbnail/.*',ThumbnailHandler),
    (r'/api/workload',WorkloadHandler),
])

if __name__ == "__main__":
    signal(SIGTERM, quit_service)

    define("port", default=2222, help="the binding port", type=int)
    define("ip", default="127.0.0.1", help="the binding ip")
コード例 #3
0
#!/usr/bin/python3

from tornado import ioloop, web
from tornado.options import define, options, parse_command_line
from redirect import RedirectHandler
from signal import signal, SIGTERM, SIGQUIT
from configuration import env
from nginx import NGINX
import json

scenario=env["SCENARIO"]
tornadoc=None
nginxc=NGINX()

def setup_scenarios():
    with open("/var/www/html/js/scenario.js","at") as fd:
        fd.write("scenarios.setting="+json.dumps(scenario.split(","))+";")

def quit_service(signum, frame):
    if tornadoc: tornadoc.add_callback(tornadoc.stop)
    nginxc.stop()
        
app = web.Application([
    (r'/api/search',RedirectHandler),
    (r'/api/stats',RedirectHandler),
    (r'/api/histogram',RedirectHandler),
    (r'/api/workload',RedirectHandler),
    (r'/api/hint',RedirectHandler),
    (r'/recording/.*',RedirectHandler),
    (r'/thumbnail/.*',RedirectHandler),
])
コード例 #4
0
from nginx import NGINX

nginx = NGINX('nginx.conf')
print(nginx.servers)
コード例 #5
0
ファイル: test.py プロジェクト: 5up3rc/nginxparser
from nginx import NGINX

nginx = NGINX('/usr/local/etc/nginx/nginx.conf')
print(nginx.locations)