Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js arguments when using forever

I'm currently using forever to run my node.js application in our development environment. What I am currently struggling with is how to pass node.js arguments when using "forever start"

Here is an example where I need to pass a number and a date to node. It's not working so any help would be appreciated.

forever -c 'node 8010 "2014-11-11 12:00:00"' start app.js
like image 398
Joofville Avatar asked Nov 11 '14 05:11

Joofville


People also ask

How do I run node JS 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.

Why do you use forever with node js?

The purpose of Forever is to keep a child process (such as your node. js web server) running continuously and automatically restart it when it exits unexpectedly.

How do I use 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.

Which is better forever or PM2?

According to the StackShare community, PM2 has a broader approval, being mentioned in 74 company stacks & 107 developers stacks; compared to forever, which is listed in 3 company stacks and 3 developer stacks.


1 Answers

According to the documentation, the script arguments come after the call. https://github.com/nodejitsu/forever

usage: forever [action] [options] SCRIPT [script-options]

forever start app.js 8010 "2014-11-11 12:00:00"

The usage of nconf https://github.com/flatiron/nconf in your project is highly recommended to grab those params.

like image 124
Will Shaver Avatar answered Sep 22 '22 12:09

Will Shaver