We use pm2 to deploy npms-analyzer, install it by running $ npm install -g pm2. You may find the pm2 configuration file in ecosystem.json5.
Before doing the first deploy, you need to setup the server. All commands executed in the server are expected to be run with analyzer user.
- Create the
analyzeruser on server - Add
analyzeruser to the list of sudoers - Install pm2 in the server
- Setup the deploy environment by running
$ pm2 deploy ecosystem.json5 production setupin your local machine - Create
~/npms-analyzer/local.json5in the server with the custom configuration (databases, GitHub API tokens, etc) - Do your first deploy by running
$ pm2 deploy ecosystem.json5 productionin your local machine - Setup logrotate by running
$ sudo pm2 logrotate -u analyzeron the server and then edit/etc/logrotate.d/pm2-wwwto change change/rootto/home/analyzer, weekly to daily, and from 12 days to 14 days) - Setup pm2 to run at start by running
$ sudo pm2 startup -u analyzer --hp "/home/analyzer"on the server - Finally run
$ pm2 saveto store the running processes
Deployment is easy, just run $ pm2 deploy ecosystem.json5 production in your local machine.