diff --git a/server.js b/server.js index ace7444..2c5da41 100644 --- a/server.js +++ b/server.js @@ -97,7 +97,7 @@ async function init(){ /*** 设置全局对象 ***/ if ('http' === wo.Config.protocol) { webServer = require('http').createServer(server).listen(wo.Config.port, function (err) { if (err) console.log(err) - else console.log(`Server listening on ${wo.Config.protocol}://${wo.Config.host}:${wo.Config.port} with IPv4=${ipv4} for ${server.settings.env} environment`) + else console.log(`[${new Date().toJSON()}] Server listening on ${wo.Config.protocol}://${wo.Config.host}:${wo.Config.port} with IPv4=${ipv4} for ${server.settings.env} environment`) }) } else if ('https' === wo.Config.protocol) { webServer = require('https').createServer(wo.Config.sslType === 'greenlock' ? greenlock.httpsOptions : { @@ -106,7 +106,7 @@ async function init(){ /*** 设置全局对象 ***/ // ca: [ fs.readFileSync(wo.Config.sslCA) ] // only for self-signed certificate: https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener }, server).listen(wo.Config.port, function (err) { if (err) console.log(err) - else console.log(`Server listening on ${wo.Config.protocol}://${wo.Config.host}:${wo.Config.port} with IPv4=${ipv4} for ${server.settings.env} environment`) + else console.log(`[${new Date().toJSON()}] Server listening on ${wo.Config.protocol}://${wo.Config.host}:${wo.Config.port} with IPv4=${ipv4} for ${server.settings.env} environment`) }) } else if ('httpall' === wo.Config.protocol) { let portHttp = wo.Config.port ? wo.Config.port : 80 // 如果port参数已设置,使用它;否则默认为80 @@ -114,14 +114,14 @@ async function init(){ /*** 设置全局对象 ***/ if (wo.Config.sslType === 'greenlock') { webServer = greenlock.listen(portHttp, portHttps, function (err) { if (err) console.log(err) - else console.log(`Server listening on [${wo.Config.protocol}] http=>https://${wo.Config.host}:${portHttp}=>${portHttps} with IPv4=${ipv4} for ${server.settings.env} environment`) + else console.log(`[${new Date().toJSON()}] Server listening on [${wo.Config.protocol}] http=>https://${wo.Config.host}:${portHttp}=>${portHttps} with IPv4=${ipv4} for ${server.settings.env} environment`) }) } else { require('http').createServer(server.all('*', function (ask, reply) { reply.redirect(`https://${wo.Config.host}:${portHttps}`) })).listen(portHttp, function(err) { if (err) console.log(err) - else console.log(`Server listening on [${wo.Config.protocol}] http://${wo.Config.host}:${portHttp} with IPv4=${ipv4} for ${server.settings.env} environment`) + else console.log(`[${new Date().toJSON()}] Server listening on [${wo.Config.protocol}] http://${wo.Config.host}:${portHttp} with IPv4=${ipv4} for ${server.settings.env} environment`) }) webServer = require('https').createServer({ key: fs.readFileSync(wo.Config.sslKey), @@ -129,7 +129,7 @@ async function init(){ /*** 设置全局对象 ***/ // ca: [ fs.readFileSync(wo.Config.sslCA) ] // only for self-signed certificate: https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener }, server).listen(portHttps, function (err) { if (err) console.log(err) - else console.log(`Server listening on [${wo.Config.protocol}] https://${wo.Config.host}:${portHttps} with IPv4=${ipv4} for ${server.settings.env} environment`) + else console.log(`[${new Date().toJSON()}] Server listening on [${wo.Config.protocol}] https://${wo.Config.host}:${portHttps} with IPv4=${ipv4} for ${server.settings.env} environment`) }) } } else if ('http2https' === wo.Config.protocol) { @@ -138,7 +138,7 @@ async function init(){ /*** 设置全局对象 ***/ reply.redirect(`https://${wo.Config.host}`) })).listen(wo.Config.port, function (err) { if (err) console.log(err) - else console.log(`Server listening on ${wo.Config.protocol}://${wo.Config.host}:${wo.Config.port} with IPv4=${ipv4} for ${server.settings.env} environment`) + else console.log(`[${new Date().toJSON()}] Server listening on ${wo.Config.protocol}://${wo.Config.host}:${wo.Config.port} with IPv4=${ipv4} for ${server.settings.env} environment`) }) }