Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update file without restart of server in Node.js

Is it possible to update a route,model or controller.js file without restarting the Node.js Server?.

I'm currently dealing with a client who wants constant changes to the application in a very frequent event. And the application deals with user session etc.. Whenever we make any changes to the application it requires a restart for the update to get reflect, which is very expensive in-terms of an high traffic situation.

I have seen some server application providing a feature called Rolling Restart but again I'm not sure whether it is a good way to maintain the user session across the restart event. Or do we have any other solution to deal with this kind of situation.

like image 230
Fahid Mohammad Avatar asked Oct 02 '15 16:10

Fahid Mohammad


1 Answers

You can restart a server without downtime yes, I recommend you take a look at PM2 https://github.com/Unitech/pm2

You can have multiple instances of node running and when you set a restart it does it gradually, making that you don't have downtime, it also distributes load to the different instances running so it speeds up your app, hope this helps :-)

like image 200
Bruno Mota Avatar answered Oct 01 '22 14:10

Bruno Mota