diff --git a/ConfigBasic.js b/ConfigBasic.js index 7646b78..e2a02ef 100644 --- a/ConfigBasic.js +++ b/ConfigBasic.js @@ -3,18 +3,23 @@ module.exports={ host: 'localhost', port: undefined, from: './dist', // local path to serve as webroot - // 如果使用 https 协议,必须填写以下内容,或在命令行参数中设置: - sslType: '', // '' or greenlock or file - sslDomainList: ['localhost'], - sslKey: undefined, // ssl key file, - sslCert: undefined, // ssl cert file, - sslCA: undefined, // ssl ca file, + + production: { + protocol: 'httpall', + host: 'remote.domain', + // 如果使用 https 协议,必须填写以下内容,或在命令行参数中设置: + sslType: 'file', // '' or greenlock or file + sslDomainList: ['remote.domain'], + sslKey: '/etc/letsencrypt/live/HOST/privkey.pem', // ssl key file, + sslCert: '/etc/letsencrypt/live/HOST/fullchain.pem', // ssl cert file, + sslCA: '/etc/letsencrypt/live/HOST/bundle.pem', // ssl ca file, + }, deploy: { type: 'web', host: 'localhost', // 待部署到的主机 port: '22', // 带部署到的主机的 SSH 端口 - dir: '/home/adot/APPNAME', // 待部署到的目录路径 + dir: '/faronear/ORG/APP', // 待部署到的目录路径 dist: 'dist', // 待部署到的文件夹 user: 'adot', // 登录用户名 password: '', // 登录用户密码 diff --git a/ConfigCustom.js b/ConfigCustom.js index 0236311..054eb83 100644 --- a/ConfigCustom.js +++ b/ConfigCustom.js @@ -1,6 +1,3 @@ module.exports={ -// sslType: 'file', -// sslKey: '/etc/letsencrypt/live/HOST/privkey.pem', // ssl key file, -// sslCert: '/etc/letsencrypt/live/HOST/fullchain.pem', // ssl cert file, -// sslCA: '/etc/letsencrypt/live/HOST/bundle.pem', // ssl ca file, + } \ No newline at end of file diff --git a/package.json b/package.json index fb3676e..af6ba22 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "vhost": "^3.0.2" }, "devDependencies": { + "pm2": "^3.5.0", "standard": "^12.0.1", "supervisor": "^0.12.0", "watchify": "^3.10.0" diff --git a/server.js b/server.js index 84addd5..d4e7f0b 100644 --- a/server.js +++ b/server.js @@ -36,6 +36,7 @@ try { // 载入命令行参数 commander .version(Config.VERSION, '-v, --version') // 默认是 -V。如果要 -v,就要加 '-v --version' + .option('-e, --env ', 'Environment. Default to ' + (Config.env || process.env.NODE_ENV)) .option('-H, --host ', `Host ip or domain name. Default to ${Config.host}`) .option('-P, --protocol ', `Web server protocol http|https|httpall|http2https. Default to ${Config.protocol}`) .option('-p, --port ', `Server port. Default to ${Config.port?Config.port:'80|443'}`) @@ -47,6 +48,12 @@ try { .parse(process.argv) // 把命令行参数 合并入配置。 + Config.env = commander.env || Config.env || process.env.NODE_ENV + if (Config.env === 'production') { + Config = deepmerge(Config, Config.production) + } + delete Config.production + Config.host=commander.host || Config.host Config.protocol=commander.protocol || Config.protocol || 'http' Config.port=parseInt(commander.port) || parseInt(Config.port) || (Config.protocol==='http'?80:Config.protocol==='https'?443:undefined) // 端口默认为 http:80, https:443, httpall: 80|443