Commit 9c93d5a8 authored by liuzheng712's avatar liuzheng712

add /ws/

parent 4f75f76d
...@@ -344,7 +344,7 @@ def download(request): ...@@ -344,7 +344,7 @@ def download(request):
def exec_cmd(request): def exec_cmd(request):
role = request.GET.get('role') role = request.GET.get('role')
check_assets = request.GET.get('check_assets', '') check_assets = request.GET.get('check_assets', '')
web_terminal_uri = '%s/exec?role=%s' % (WEB_SOCKET_HOST, role) web_terminal_uri = '/ws/exec?role=%s' % (role)
return my_render('exec_cmd.html', locals(), request) return my_render('exec_cmd.html', locals(), request)
...@@ -356,7 +356,8 @@ def web_terminal(request): ...@@ -356,7 +356,8 @@ def web_terminal(request):
if asset: if asset:
print asset print asset
hostname = asset.hostname hostname = asset.hostname
web_terminal_uri = '%s/ws/terminal?id=%s&role=%s' % (WEB_SOCKET_HOST, asset_id, role_name) # web_terminal_uri = '%s/ws/terminal?id=%s&role=%s' % (WEB_SOCKET_HOST, asset_id, role_name)
web_terminal_uri = '/ws/terminal?id=%s&role=%s' % (asset_id, role_name)
return render_to_response('jlog/web_terminal.html', locals()) return render_to_response('jlog/web_terminal.html', locals())
...@@ -442,7 +442,7 @@ def main(): ...@@ -442,7 +442,7 @@ def main():
(r'/monitor', MonitorHandler), (r'/monitor', MonitorHandler),
(r'/ws/terminal', WebTerminalHandler), (r'/ws/terminal', WebTerminalHandler),
(r'/kill', WebTerminalKillHandler), (r'/kill', WebTerminalKillHandler),
(r'/exec', ExecHandler), (r'/ws/exec', ExecHandler),
(r"/static/(.*)", tornado.web.StaticFileHandler, (r"/static/(.*)", tornado.web.StaticFileHandler,
dict(path=os.path.join(os.path.dirname(__file__), "static"))), dict(path=os.path.join(os.path.dirname(__file__), "static"))),
('.*', tornado.web.FallbackHandler, dict(fallback=container)), ('.*', tornado.web.FallbackHandler, dict(fallback=container)),
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
protocol = 'wss://'; protocol = 'wss://';
} }
var wsUri = protocol + "{{ web_terminal_uri }}"; //请求的websocket url var wsUri = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + "{{ web_terminal_uri }}"; //请求的websocket url
var ws = new WebSocket(wsUri); var ws = new WebSocket(wsUri);
function createSystemMessage(message) { function createSystemMessage(message) {
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
protocol = 'wss://'; protocol = 'wss://';
} }
var endpoint = protocol + '{{ web_terminal_uri }}'; var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '{{ web_terminal_uri }}';
if (window.WebSocket) { if (window.WebSocket) {
this._connection = new WebSocket(endpoint); this._connection = new WebSocket(endpoint);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment