版本
node: v12.20.1
pkg: v5.8.0
pkg-fetch: 12.22.11
下载地址: (https://github.com/vercel/pkg-fetch/releases)
配置
// default.config.js
config.static = {
prefix: '/public',
dir: process.cwd() + '/public',
};
config.rundir = process.cwd() + '/run';
config.logger = {
dir: path.join(process.cwd(), 'logs', '/'), // 配置普通日志文件地址
outputJSON: false,
};
// package.js
"pkg": {
"scripts": [
"./app/**/*.js",
"./config/*.js",
"./config/*",
"./app.js",
"./node_modules/nanoid/**/*.js",
"./node_modules/nanoid/**/*.cjs"
],
"assets": [],
"targets": [
"node12-win-x64"
]
},
"bin": "build.js",
// build.js
'use strict';
const egg = require('egg');
const workers = Number(process.argv[2] || require('os').cpus().length);
egg.startCluster({
workers,
baseDir: __dirname,
});