diff --git a/ConfigBasic.js b/ConfigBasic.js new file mode 100644 index 0000000..9647e3c --- /dev/null +++ b/ConfigBasic.js @@ -0,0 +1,22 @@ +module.exports={ + protocol: 'http', + host: 'localhost', + port: undefined, + // 如果使用 https 协议,必须填写以下内容,或在命令行参数中设置: + sslType: 'greenlock', // greenlock or file + sslDomainList: ['localhost'], + sslKey: undefined, // '/etc/letsencrypt/live/HOST/privkey.pem', // ssl key file, + sslCert: undefined, // '/etc/letsencrypt/live/HOST/fullchain.pem', // ssl cert file, + sslCA: undefined, // '/etc/letsencrypt/live/HOST/bundle.pem', // ssl ca file, + + deploy: { + type: 'web', + host: 'localhost', // 待部署到的主机 + port: '22', // 带部署到的主机的 SSH 端口 + dir: '/home/adot/APPNAME', // 待部署到的目录路径 + dist: 'dist', // 待部署到的文件夹 + user: 'adot', // 登录用户名 + password: '', // 登录用户密码 + key: `${process.env.HOME}/.ssh/id_rsa`, // 登录用户私钥文件 + }, +} \ No newline at end of file diff --git a/ConfigCustom.js b/ConfigCustom.js new file mode 100644 index 0000000..0236311 --- /dev/null +++ b/ConfigCustom.js @@ -0,0 +1,6 @@ +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/server.js b/server.js index 98353fb..ace7444 100644 --- a/server.js +++ b/server.js @@ -13,14 +13,20 @@ try { if (fs.existsSync(path.join(process.cwd(), './ConfigBasic.js'))) { Config=require(path.join(process.cwd(), './ConfigBasic.js')) console.info('ConfigBasic loaded') + }else { + console.info('Missing and omitting ConfigBasic') } if (fs.existsSync(path.join(process.cwd(), './ConfigCustom.js'))) { // 如果存在,覆盖掉 ConfigBasic 里的默认参数 Config=deepmerge(Config, require(path.join(process.cwd(), './ConfigCustom.js'))) // 注意,objectMerge后,产生了一个新的对象,而不是在原来的Config里添加 console.info('ConfigCustom loaded') + }else { + console.info('Missing and omitting ConfigCustom') } if (fs.existsSync(path.join(process.cwd(), './ConfigSecret.js'))) { // 如果存在,覆盖掉 ConfigBasic 和 ConfigCustom 里的参数 Config=deepmerge(Config, require(path.join(process.cwd(), './ConfigSecret.js'))) console.info('ConfigSecret loaded') + }else { + console.info('Missing and omitting ConfigSecret') } }catch(err){ console.error('Loading config files failed: '+err.message) @@ -82,7 +88,7 @@ async function init(){ /*** 设置全局对象 ***/ server.use(require('compression')()) /*** 路由 ***/ - server.use(require('express').static(path.join(__dirname, 'dist'), {index: 'index.html'})) + server.use(require('express').static(path.join(process.cwd(), 'dist'), {index: 'index.html'})) // server.use(require('serve-favicon')(path.join(__dirname, 'public', 'favicon.ico'))) // uncomment after placing your favicon in /public let ipv4 = getMyIp()