Question

Is there a way to toggle restarting nodejs for only certain files using node-dev or the like?

I've looked and it seems require.extensions is an object that holds the extensions in which to restart for, though deleting it doesn't seem to do anything.

What I want is to be able to use node-dev as usual, but have certain files be required without restarting, so I can watch them manually and reload them without restarting everything.

Was it helpful?

Solution

Hot-(re)loading modules is a hot potato, to say the least. Modules assume that when they are loaded, they are done so into a clean environment, and hot-loading changes that. It opens up for all kinds of scary bugs such as memory leaks and broken memory pointers and is in my honest opinion not worth the hassle. Here's a similar question with a good answer.

Quite relevant to the subject, one of the projects I am working on right now: overseer

It's an experimental cluster manager that wraps your workers and gives you the ability to watch for file system changes and do rolling restarts of the workers (restart them one by one), so there's no experienced downtime.

However, there's currently no way to attach a client to a specific worker, so in a worst case scenario the client will be dealing with two or more workers that are running different versions of your app. Not the most ideal of situations :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top