EzDevInfo.com

PM2

Production process manager for Node.js / io.js applications. Perfectly fitted for microservices architecture. PM2 - Advanced Node.js process manager advanced process manager for production node.js applications. load balancer, logs facility, startup script, micro service management, at a glance.

sailsjs using pm2 cluster mode and CSRF

I am running a sailsjs app with pm2 and its cluster mode.

The problem now is that since I am making cross domain requests with CSRF validation, only one of the clusters has the right access, the others give me the "CSRF mismatch error".

How do you use the pm2 with CSRF?


Source: (StackOverflow)

How to pass arguments to app using pm2?

I am using pm2 to start my app but i am not able to pass argument to it. the command I am using is pm2 start app.js -- dev. Though this works with forever.


Source: (StackOverflow)

Advertisements

pm2 process manager not working

I install the pm2 using npm install -g pm2 then when I run my node application using

pm2 start app.js

nothing is happening. when I run the command in terminal, it just go down another line. No errors or warnings shows in the terminal. I can run the application using nodejs app.js . Any kind of help would be appreciated. Thanks.


Source: (StackOverflow)

How can I run pm2 on a certain node version?

There are several different versions of node running on our linux server, And my service is based on node v0.11.14. However, other people's code have to run on lower version of node(lower than v0.11) otherwise their services will be out of service. So I can't define the global node version as v0.11. I just want to run pm2 to monitor my service based on node v0.11.

Is there anyway to run my pm2 on node v0.11 without changing the global node version? Thanks


Source: (StackOverflow)

nodejs PM2 cluster mode for load balancing

When using pm2 cluster there's a pretty severe warning saying you shouldn't use it in production, nor for load balancing, use nginx instead. Unfortunately that's exactly how I planned to use PM2. Is it really not intended to be used for that purpose or is it just not completely ready yet?


Source: (StackOverflow)

How to add dates to pm2 error logs?

Is there a way to add timestamps to error logs in .pm2/logs?

I noticed that pm2 logs command shows aggregated logs with timestamps, but looking into log files - there are only messages and stacktraces without dates.

enter image description here


Source: (StackOverflow)

Express 4 + pm2 watch not working

I'm running pm2 with this:

pm2 start bin/www --watch ../

Problem is that when I update app.js in the root folder, it doesn't seem to be autorestarting node. Any ideas?


Source: (StackOverflow)

How to use Grunt/Gulp with pm2?

pm2 is a great tool to manage node apps. How does it work with grunt/glup ? I didn't find any useful clues after Googling for 20 minutes.


Source: (StackOverflow)

How to add production mode to sailsjs app when started using PM2

To start sailsjs in production mode you append --prod.

Run: node app.js --prod

I'm using PM2 and a simple json file for settings, which contains name of process and scriptname, to kick off the node process.

How would I pass the production argument using PM2?


Source: (StackOverflow)

Forever errors with babel-node

I have a simple node server:

//server.js

import express  from 'express';
import React    from 'react';
...

When I try to run this using Forever:

forever start -c "babel-node --experimental" server.js , it errors out due to use of import

/Applications/MAMP/htdocs/React/ReactBoilerplates/koba04/app/server.js:1
(function (exports, require, module, __filename, __dirname) { import express  
                                                              ^^^^^^
SyntaxError: Unexpected reserved word
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3
error: Forever detected script exited with code: 8

I have also tried pm2 and nodemon, I get same error there as well. For pm2, I followed this issue https://github.com/Unitech/PM2/issues/1167, but it didn't work either. What am I doing wrong here?


Source: (StackOverflow)

NodeJS on multiple processors (PM2, Cluster, Recluster, Naught)

I am investigating options for running node in a multi-core environment.

I'm trying to determine the best approach and so far I've seen these options

  • Use built in cluster library to spin up works and respond to signals
  • Use PM but, PM2 -i is listed as beta.
  • Naught
  • Recluster

Are there other alternatives? What are folks using in production?


Source: (StackOverflow)

How to start node.js app with pm2 in cluster mode?

We are trying to start our app with pm2 0.12.8 on ubuntu 14.04 with octa core proccessor. The read me on the git hub has a very straight forward command for running node app in cluster mode.

# Cluster mode

$ pm2 start app.js -i 0        **# Will start maximum processes with LB depending on available CPUs**
$ pm2 start app.js -i max      **# Same as above, but deprecated yet.**

But the above command are not working for us. When we try to run these commands only one instance is listed by pm2.

Why? Any suggestion

Thanks


Source: (StackOverflow)

Correct usage of PM2 for Node?

I am considering switching from forever to PM2 to keep my node application up and running.

I am confused about the following recommended methods for starting a process:

$ pm2 start app.js -i 4 # Daemonize pm2 and Start 4 clustered instances of app.js
                        # You can also pass the 'max' params to start

Could someone explain to me what is a clustered instance of app.js? How many instances should I start? 1? Max?


Source: (StackOverflow)

mongoError: Topology was destroyed

I have a REST service built in node.js with Restify and Mongoose and a mongoDB with a collection with about 30.000 regular sized documents. I have my node service running through pmx and pm2.

Yesterday, suddenly, node started crapping out errors with the message "MongoError: Topology was destroyed", nothing more. I have no idea what is meant by this and what could have possibly triggered this. there is also not much to be found when google-searching this. So I thought I'd ask here.

After restarting the node service today, the errors stopped coming in. I also have one of these running in production and it scares me that this could happen at any given time to a pretty crucial part of the setup running there...

I'm using the following versions of the mentioned packages:

  • mongoose: 4.0.3
  • restify: 3.0.3
  • node: 0.10.25

Source: (StackOverflow)

PM2 resurrect not working on reboot - dump.pm2 being emptied

I'm trying to configure PM2 to daemonize a simple node.js server on centos. The init.d script executes, and there are no errors, but pm2 list returns an empty list, and the server is not starting.

Originally, I was attempting to start the process as a different user (for those interested, this can be done with modifications to pm2-init.sh). But due to the complication, I decided to first try to get it to run as root.

The strange symptom of the problem is that the dump.pm2 file is being emptied by some process, thus the pm2 resurrect has nothing to do. I set up pm2 to run on reboot as follows

$ pm2 startup centos
$ pm2 start /path/to/my/server.js
$ pm2 save

At this point, dump.pm2 had a large JSON object in it and the server is running. Then, running:

$ reboot
  ... wait and log back in
$ pm2 list

It was empty again, and so was the dump.pm2!

I'm not sure what process is clearing this file. I've tried reinstalling and re-running the startup script to no avail. Any help is greatly appreciated.


Source: (StackOverflow)