chain handler. remove debug log
This commit is contained in:
parent
e64d1b3c69
commit
c2d672519a
1 changed files with 20 additions and 22 deletions
|
|
@ -44,7 +44,7 @@ function guid() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function time() {
|
function time() {
|
||||||
return new Date().getTime();
|
return Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1039,7 +1039,7 @@ function initModule(file, dir) {
|
||||||
ws: {
|
ws: {
|
||||||
register: ws_register_root
|
register: ws_register_root
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleStatic(root, pre) {
|
function handleStatic(root, pre) {
|
||||||
|
|
@ -1118,7 +1118,7 @@ modPaths.forEach(fn => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// add the rest of the handler chain
|
// add the rest of the handler chain
|
||||||
let server = handler.use(fullpath({
|
handler.use(fullpath({
|
||||||
"/meta/index.html" : redir("/meta/"),
|
"/meta/index.html" : redir("/meta/"),
|
||||||
"/kiri/index.html" : redir("/kiri/"),
|
"/kiri/index.html" : redir("/kiri/"),
|
||||||
"/meta" : remap("/meta/index.html"),
|
"/meta" : remap("/meta/index.html"),
|
||||||
|
|
@ -1137,25 +1137,23 @@ let server = handler.use(fullpath({
|
||||||
.use(rewriteHTML)
|
.use(rewriteHTML)
|
||||||
.use(compression)
|
.use(compression)
|
||||||
.use(handleStatic(currentDir + "/web/"))
|
.use(handleStatic(currentDir + "/web/"))
|
||||||
.listen(port);
|
.listen(port)
|
||||||
|
.on('upgrade', (request, socket, head) => {
|
||||||
server.on('upgrade', (request, socket, head) => {
|
let handler = wss_roots[request.url];
|
||||||
let handler = wss_roots[request.url];
|
if (handler) {
|
||||||
if (handler) {
|
wss.handleUpgrade(request, socket, head, ws => {
|
||||||
log({request: request.url})
|
try {
|
||||||
wss.handleUpgrade(request, socket, head, ws => {
|
handler(ws, request);
|
||||||
try {
|
} catch (err) {
|
||||||
handler(ws, request);
|
log({wss_handler_error: err});
|
||||||
} catch (err) {
|
ws_delete_root(request.url);
|
||||||
console.log({wss_handler_error: err});
|
socket.destroy();
|
||||||
ws_delete_root(request.url);
|
}
|
||||||
socket.destroy();
|
});
|
||||||
}
|
} else {
|
||||||
});
|
socket.destroy();
|
||||||
} else {
|
}
|
||||||
socket.destroy();
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
helper.log("------------------------------------------");
|
helper.log("------------------------------------------");
|
||||||
helper.log({port, debug, nolocal, version: ver.VERSION});
|
helper.log({port, debug, nolocal, version: ver.VERSION});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue