thesuhu

Nodejs PM2

Oct 16th, 2020 (edited)
2,446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.74 KB | None | 0 0
  1. # start PM2 tanpa file ecosystem
  2. pm2 start bin/www -i max --log-date-format "DD-MM-YY HH:mm:ss.SSS"
  3. pm2 status
  4.  
  5. # menjalankan ulang pm2
  6. pm2 stop all
  7. pm2 kill
  8. pm2 start bin/www -i max --log-date-format "DD-MM-YY HH:mm:ss.SSS"
  9. pm2 status
  10. # mengatasi dot env tidak terbaca
  11. # The solution was easy. You have to declar cwd, aka the project folder where the dotenv/config will be read from.
  12. module.exports = {
  13.   apps: [{
  14.     name: 'app1 name',
  15.     script: 'app1.js',
  16.     cwd: '/path/to/folder/',
  17.     exec_mode: 'fork_mode',
  18.     node_args: '-r dotenv/config',
  19.   }, {
  20.     name: 'app2 name',
  21.     script: 'app2.js',
  22.     cwd: '/path/to/folder/',
  23.     instances: 'max',
  24.     exec_mode: 'cluster',
  25.     node_args: '-r dotenv/config',
  26.   }],
  27. };
Add Comment
Please, Sign In to add comment