Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

starting node forever script with PORT=XXXX

when running node in command over a specific port, I'd start the app this way:

PORT=1234 node app.js

how do I pass the port to the forever command? no matter what I try, it seems to not want to work.

I've tried:

  • passing the port as an arg: forever start app.js 1234
  • passing the port declaration as an arg: forever start app.js PORT=1234
like image 507
Kristian Avatar asked Aug 21 '15 05:08

Kristian


People also ask

How do I start node on forever?

js application locally after closing the terminal or Application, to run the nodeJS application permanently. We use NPM modules such as forever or PM2 to ensure that a given script runs continuously. NPM is a Default Package manager for Node.

What is the default port for Nodejs?

The default port for HTTP is 80 – Generally, most web browsers listen to the default port. Below is the code implementation for creating a server in node and making it listen to port 80.

How do I use npm forever?

What is npm forever? Forever is an npm package used to keep your script running continuously in the background. It's a handy CLI tool that helps you to manage your application in the development and production stages. To start running a script with forever, use the forever start command, followed by the script name.


2 Answers

PORT=1234 forever start app.js 
like image 165
Hiren S. Avatar answered Oct 28 '22 11:10

Hiren S.


You can try adding export PORT=1234 to app.js Then just run with forever start app.js

like image 29
Ivailo Stoianov Avatar answered Oct 28 '22 12:10

Ivailo Stoianov