简体   繁体   中英

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.

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 :-)

Nodemon is what I have used before and I was very happy with it.

Install

npm install -g nodemon

then run your app with

nodemon [your node app]

Done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM