Use with pm2
- The framework inherits
pm2
, you can add the following command in package.json
"scripts": {
"dev": "ndsk",
"start": "ndsk start --pm2"
"build": "ndsk build",
},
ndsk start --pm2
means starting production mode withpm2
, you can configurepm2
inndsk.config.json
module.exports = (isPro)=>{
return {
server:{
port:isPro ? 3001 : 3000,
},
pm2:isPro ? {
name:"production",
instances : 2,
out_file:'./pm2/logs.txt',
error_file:'./pm2/error.txt'
} : { }
}
}
- The above means that two processes are started in the production environment, the log files are stored in
./pm2/logs.txt
, and the error logs are stored in./pm2/error.txt
- You can view the
pm2
related documents here - Visit http://localhost:3001
$ npm run build
$ npm run start
$ pm2 list