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! :)
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.
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.
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.
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.
Several guesses.
sudo npm install forever -g
, you might need to sudo
to run forever.forever start /home/you/source/server.js
or sudo forever start /home/you/source/server.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With