lang/node

pm2 npm start

C/H 2019. 11. 14. 13:53

Run pm2 npm

pm2 start npm -- start

ecosystem.config.js

module.exports = {
	apps: [{
		name: "utilservice",
		script: "./bin/www",
		instanses: "max",
		exec_mode: "cluster",
		env: {
			NODE_ENV: "production"
		},
		log_date_format: "YYYY-MM-DD HH:mm:ss.SSS",
		error_file: "./logs/pm2-err.log",
		out_file: "./logs/pm2-out.log",
		combine_logs: true,
		merge_logs: true
	}]
}

package.json

{
"name: "app_name",
"script": {
    "start": "NODE_ENV=production node ./bin/www --app_name &",
    "pm2": "NODE_ENV=production pm2 start --name app_name ./bin/www --log-date-format 'DD-MM HH:mm:ss.SSS' -i max",
    "eco": "NODE_ENV=production pm2 start ecosystem.josn.js",
    "stop": "ps aux | grep app_name | grep -v grep | awk '{print $2}' | xargs kill -9",
    "dev": "DEBUG=* NODE_ENV=development node ./bin/www --app_name --inspect --watch &",
    "ps": "ps aux | grep app_name | grep -v grep"
  }
}

Run Command

npm start pm2
npm start echo
반응형