How Can I run PM2 with Angular-Cli? - Angular2
This command would work as expected:
after I run
ng build --prod
then run the following command in the dist/ folder
pm2 start /usr/bin/http-server -- -p 8080 -d false
Update
I have found a better solution:which ng
then it will print /usr/bin/ngthen type this
pm2 start /usr/bin/ng -- serve --prod
But, if you need ng serve for dev in preprod env, you can create a start.sh at root of your project
#!/bin/bashng serve --host xxx.xxx.xxx.xxx --port xxxx
And use pm2 like that :
pm2 start start.sh --name my-pretty-dev-app-run-on-preprod
;)
With PM2 recent version
pm2 ecosystem
than update
ecosystem.config.js as follows
module.exports = { apps : [{ name: 'demoapp', script: 'node_modules/@angular/cli/bin/ng', args: 'serve --host [yourip] --disable-host-check', instances: 1, autorestart: true, watch: false, max_memory_restart: '1G', env: { NODE_ENV: 'development' }, env_production: { NODE_ENV: 'production' } }], deploy : { }};
finally
pm2 start & pm2 save