mirror of https://github.com/jumpserver/jumpserver
feat(run_websocket.py): add main function, it need only run run_websocket.py
I want to run one program at once, open two terminal is ridiculouspull/86/head
parent
d0ba0503e5
commit
92e9f988f3
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
@ -31,7 +32,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
|
||||||
define("port", default=3000, help="run on the given port", type=int)
|
define("port", default=3000, help="run on the given port", type=int)
|
||||||
define("host", default='0.0.0.0', help="run port on given host", type=str)
|
define("host", default='0.0.0.0', help="run port on given host", type=str)
|
||||||
|
|
||||||
|
@ -425,12 +426,40 @@ class Application(tornado.web.Application):
|
||||||
tornado.web.Application.__init__(self, handlers, **setting)
|
tornado.web.Application.__init__(self, handlers, **setting)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
tornado.options.parse_command_line()
|
from django.core.wsgi import get_wsgi_application
|
||||||
app = Application()
|
import tornado.wsgi
|
||||||
server = tornado.httpserver.HTTPServer(app)
|
wsgi_app = get_wsgi_application()
|
||||||
server.bind(options.port, options.host)
|
container = tornado.wsgi.WSGIContainer(wsgi_app)
|
||||||
#server.listen(options.port)
|
setting = {
|
||||||
server.start(num_processes=5)
|
'cookie_secret': 'DFksdfsasdfkasdfFKwlwfsdfsa1204mx',
|
||||||
print "Run server on %s:%s" % (options.host, options.port)
|
'template_path': os.path.join(os.path.dirname(__file__), 'templates'),
|
||||||
|
'static_path': os.path.join(os.path.dirname(__file__), 'static'),
|
||||||
|
'debug': False,
|
||||||
|
}
|
||||||
|
tornado_app = tornado.web.Application(
|
||||||
|
[
|
||||||
|
# (r'/monitor', MonitorHandler),
|
||||||
|
(r'/terminal', WebTerminalHandler),
|
||||||
|
(r'/kill', WebTerminalKillHandler),
|
||||||
|
(r'/exec', ExecHandler),
|
||||||
|
(r"/static/(.*)", tornado.web.StaticFileHandler,
|
||||||
|
dict(path=os.path.join(os.path.dirname(__file__), "static"))),
|
||||||
|
('.*', tornado.web.FallbackHandler, dict(fallback=container)),
|
||||||
|
], **setting)
|
||||||
|
|
||||||
|
server = tornado.httpserver.HTTPServer(tornado_app)
|
||||||
|
server.listen(options.port)
|
||||||
|
|
||||||
tornado.ioloop.IOLoop.instance().start()
|
tornado.ioloop.IOLoop.instance().start()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# tornado.options.parse_command_line()
|
||||||
|
# app = Application()
|
||||||
|
# server = tornado.httpserver.HTTPServer(app)
|
||||||
|
# server.bind(options.port, options.host)
|
||||||
|
# #server.listen(options.port)
|
||||||
|
# server.start(num_processes=5)
|
||||||
|
# print "Run server on %s:%s" % (options.host, options.port)
|
||||||
|
# tornado.ioloop.IOLoop.instance().start()
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue