forked from svrjs/svrjs
Fixed server crashes while one of two ports are in use
This commit is contained in:
parent
2d266bf1b3
commit
94a7b319f6
3 changed files with 13 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
||||||
"port": 80,
|
"port": 80,
|
||||||
"pubport": 80,
|
"pubport": 80,
|
||||||
"page404": "404.html",
|
"page404": "404.html",
|
||||||
"timestamp": 1692477525860,
|
"timestamp": 1692915666757,
|
||||||
"blacklist": [],
|
"blacklist": [],
|
||||||
"nonStandardCodes": [],
|
"nonStandardCodes": [],
|
||||||
"enableCompression": true,
|
"enableCompression": true,
|
||||||
|
|
|
@ -67,6 +67,7 @@ if(href == "/hello.svr") {
|
||||||
//Prevent open proxy
|
//Prevent open proxy
|
||||||
callServerError(403,"SVR.JS-exampleproxy"); //Server error
|
callServerError(403,"SVR.JS-exampleproxy"); //Server error
|
||||||
serverconsole.errmessage("Client fails to recieve content."); //Log into SVR.JS
|
serverconsole.errmessage("Client fails to recieve content."); //Log into SVR.JS
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
var hdrs = req.headers;
|
var hdrs = req.headers;
|
||||||
hdrs["Host"] = (hn == "this" ? req.headers.host : hn);
|
hdrs["Host"] = (hn == "this" ? req.headers.host : hn);
|
||||||
|
|
16
svr.js
16
svr.js
|
@ -4863,11 +4863,17 @@ function start(init) {
|
||||||
|
|
||||||
|
|
||||||
if (!cluster.isPrimary) {
|
if (!cluster.isPrimary) {
|
||||||
if (secure) {
|
try {
|
||||||
server.listen(sport);
|
server.listen(secure ? sport : port);
|
||||||
if (!disableNonEncryptedServer) server2.listen(port);
|
} catch(err) {
|
||||||
} else {
|
if(err.code != "ERR_SERVER_ALREADY_LISTEN") throw err;
|
||||||
server.listen(port);
|
}
|
||||||
|
if (secure && !disableNonEncryptedServer) {
|
||||||
|
try {
|
||||||
|
server2.listen(port);
|
||||||
|
} catch(err) {
|
||||||
|
if(err.code != "ERR_SERVER_ALREADY_LISTEN") throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue