默认只启动 http server,不要 https server。

This commit is contained in:
lulu
2018-10-22 17:21:33 +08:00
parent a983ffce14
commit 8f47119c6b
2 changed files with 7 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
module.exports={
protocol:'httpall',
protocol:'http',
host:'localhost',
port:undefined,
// 如果使用 https 协议,必须填写以下内容,或在命令行参数中设置:

View File

@@ -28,7 +28,7 @@ try {
// 载入命令行参数
commander
.version(Config.VERSION, '-v, --version') // 默认是 -V。如果要 -v就要加 '-v --version'
.option('-h, --host <host>', 'host ip or domain name')
.option('-H, --host <host>', 'host ip or domain name')
.option('-P, --protocol <protocol>', 'Web server protocol http|https|httpall, default to httpall')
.option('-p, --port <port>', 'Server port, default to 80|443')
.option('--sslCert <cert>', 'SSL cert file')
@@ -37,8 +37,8 @@ try {
.parse(process.argv)
// 把命令行参数 合并入配置。
Config.host=commander.host || Config.host || 'localhost'
Config.protocol=commander.protocol || Config.protocol || 'httpall' // 默认同时启用 http 和 https
Config.host=commander.host || Config.host
Config.protocol=commander.protocol || Config.protocol // 默认同时启用 http 和 https
Config.port=parseInt(commander.port) || parseInt(Config.port) || (Config.protocol==='http'?80:Config.protocol==='https'?443:undefined) // 端口默认为 http:80, https:443, httpall: 80|443
Config.sslCert=commander.sslCert || Config.sslCert
Config.sslKey=commander.sslKey || Config.sslKey
@@ -76,16 +76,12 @@ async function init(){ /*** 设置全局对象 ***/
server.use(compression())
/*** 路由 ***/
//server.use(express.static(path.join(__dirname,'dist'), {index:'index.html'}))
var webroot=express.static(path.join(__dirname,'dist'), {index:'index.html'})
server.use(webroot)
server.use(express.static(path.join(__dirname,'dist'), {index:'index.html'}))
// var vhost = require('vhost')
// var webroot=express.static(path.join(__dirname,'dist'), {index:'index.html'})
// server.use(vhost('bittic.org', webroot))
// server.use(vhost('www.bittic.org', webroot))
// server.use(vhost('box.bittic.org', express.static(path.join(__dirname,'../ticbox/dist'), {index:'index.html'})))
// server.use(vhost('wallet.bittic.org', express.static(path.join(__dirname,'../ticwalletx/dist'), {index:'index.html'})))
// server.use(vhost('*', webroot))
// server.use(vhost('*.*', webroot))
// server.use(vhost('*.*.*', webroot))