webfaction - How to restart PM2 itself when the server processes are killed?

I use PM2 to run my node.js app. It works fine, however, sometimes my web hosting provider WebFaction (hello!) kills all the processes on my part of the shared server when my app goes beyond the memory limit (it's actually a java-based neo4j graph database doing that and I'm working on resolving this issue).When this happens, PM2, for some reason thinks it is still running, even though my app is not online (while the database is restarted using a cron). How do I make sure PM2 "knows" when something like this happens and restarts my node.js app ...Read more

Debug application which is run using pm2

Application is run bypm2 start app.jsorpm2 start config.jsonI want to debug my application locally using node_inspector. I added debug argumentpm2 start --node-args="--debug=7000" app.jsIt works fine but if I provide config.json instead of script app.js I don't know how to pass arguments about debug. Next piece of config doesn't work{ "apps": [ { "name": "myName", "script": "app.js", "args": "['--debug=7000']" ............ } ]}So How to debug application which is run by pm2 and using config?...Read more

PM2: Deploy multiple environments on a single server?

I am using PM2 for deployment / process management, and the application handles lots of DNS tasks, and so it's easiest if I run the development app from the remote server, and either Rsyncing or SFTPing on save (still sorting this out).This being the case, it is the idea case for the dev app to be on the same VM as the production app. However, the structure of the PM2 deployment configuration file (ecosystem.config.js) doesn't seem to make this possible, as when I run pm2 deploy development, the development version overtakes the production proc...Read more

Getting restart count from PM2 node

I'm trying to monitor the amount of the restarts, cpu and memory in PM2 module managed microservices and create an alert if the module is restarting using AWS cloud watch.pm2 list Command returns the data in a UI formatted way which I would like to avoid parsing.Is there any way to get the number of process restarts in a more machine-readable friendly format than the one returned by the pm2 list command.I looked at the pm2 get command but can't find documentation about the keys I can use there....Read more

pm2: unknown option `--run-as-user'

I'm following a tutorial on working with git and ghost and they use pm2 to manage the ghost process, but after I do local changes and push them with git push web I get error:pm2: unknown option `--run-as-user'These are the contents of my hooks/post-receive file:#!/bin/shexport NODE_ENV=productionGIT_WORK_TREE=/var/www/ghost git checkout -fcd /var/www/ghostpm2 killnpm install --productionchown -R ghost:ghost /var/www/ghostpm2 start index.js --run-as-user ghost --name ghost # THIS MIGHT BE DEPRECATED...Read more

pm2 deploy production and staging to same serve with different app names

I would like to deploy staging and production on the same server with different names, but i don't see anyway to achieve this given the documentation for pm2 ecosystem files. here is my ecosystem.config.js below:module.exports = { apps : [{ name: 'frontend', script: 'server/index.js', // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/ instances: 1, autorestart: true, watch: false, max_memory_restart: '256M', env: { NODE_ENV: 'development' }, env_staging: { NODE_ENV: 'staging', ...Read more

Should PM2 God Daemon always be running?

I use pm2 to deal with node projects. Even when all projects are stopped via pm2, I see that pm2 God Daemon is always running and consuming about ~27M Ram. Here how it looks on ps aux: nodeuser 2577 ? Ssl 18:02 0:01 PM2 v0.15.10: God DaemonThe question is, is it built to be that way? Should pm2 God Daemon always be running? However if it is the case, I would like to know why because it didn't make sense to me. Can I kill pm2 God Daemon via pm2? Or simply kill with kill -9 pid?...Read more

What does the command line arguments for PM2 startup mean precisely

I am a little confused about start up scripts and the command line options. I am building a small raspberry pi based server for my node applications. In order to provide maximum protection against power failures and flash write corruption, the root file system is read only, and that embraces the home directory of my main user, were the production versions of my apps (two of them) are stored. Because the .pm2 directory here is no good for logs etc I currently set PM2_HOME environment variable to a place in /var (which has 512kb unused space a...Read more

pm2 - nvm management node version

I used the nvm management node version, installed two versions, one is 6.10.1, one is 7.7.4, but in koa2 project, nvm use 7, use pm2 open cluster mode, can not start normally. Pm2 logs error: /root/.nvm/versions/node/v6.10.1/bin/node: bad option: --harmony-async-await. However, I am in the pm2 process file defined in the "interpreter": "/ root / .nvm / versions / node / v7.7.4 / bin / node", why not I specified the version of the node?...Read more

pm2 only show name and status for each process

so if I use "pm2 list" to show all added scripts it shows me a quite a lot of information about them.But the only thing I want is the name and the status for each process.Like this for example:Name Statusscript1 Onlinetest123 Offlineabc OnlineIs there a way to get rid off all the other information?...Read more

pm2 doesn't work with config json however works with direct command

I am using pm2 to manage my node js server. Strangly when I use pm2.config.json file then it doesn't recognize the relative paths and node js server fails to load the file and try to kill node js process and when pm2 see node process is kills then it try to restart node and went to infinite loop. Following are details.pm2.config.json{ "apps": [ { "name": "Application", "script": "./server.js", "watch": false } ]}Command to start pm2:pm2 start dist/BHS/pm2.config.jsonEr...Read more