Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs 'forever' just doesn't do anything

I am trying to run my nodejs app on an Amazon EC2 instance using forever. I installed nodejs npm, and then ran sudo npm install forever -g.
The installation didn't return any errors, so i go ahead and try running my app using forever start server.js, but it won't do anything - no output what-so-ever, not even an error.
I also tried forever --help and just forever, but none of them giving me any response...

When running my app regularly using nodejs - nodejs init.js then it works as expected, but i need to get it running using forever so it won't shut down when i disconnect from the server.

Edit :
Since the only problem i was having was that nodejs was closing when i closed the terminal session to my EC2 server, I solved this by using the linux nohup command like this :
nohup sudo nodejs server.js &
This kept nodejs running in a child process even after I closed the terminal window.

Thanks for the help though! :)

like image 395
gillyb Avatar asked Feb 13 '13 19:02

gillyb


People also ask

Why do you use forever with node js?

Forever is an npm module that ensures a Node. js script continuously runs in the background on the server. It's a helpful CLI tool for the production environment because it helps manage the Node applications and their processes.

Does node js have a future in 2022?

js, React. js, Node. js) will keep their leading positions in app development in 2022. They are robust solutions for building dynamic and single-page web applications.

When should we not use Nodejs?

Avoid Using Node. js: Processing CPU heavy and complex applications: Node. js uses an event-based, non-blocking I/O architecture and only has one CPU – all of that intensive CPU processing would block incoming requests. As a result of the high-end number crunching, the thread might get stuck.

Is node obsolete?

js 10, which reaches its offical end of life on April 30th 2021. On April 20th 2021, Node. js 10 will be disabled in the Project Settings and existing Projects that have Node.


1 Answers

Several guesses.

  • If you install using sudo npm install forever -g, you might need to sudo to run forever.
  • Put a full path of server.js when you run forever such as forever start /home/you/source/server.js or sudo forever start /home/you/source/server.js
like image 161
Won Avatar answered Oct 09 '22 21:10

Won