3

I'm currently using node-supervisor so that node picks up .js changes, it works good but I've noticed it restarts the server everytime I save a js file. Is there a way to save a server-side .js file but not restart the server, yet have the changes automatically loaded into node? I.e., the process won't exit but somehow just update itself with the new changes.

Shai UI
  • 45,518
  • 63
  • 187
  • 278
  • I'd be surprised if that's possible, probably not – mihai Feb 20 '14 at 21:17
  • How would you expect "somehow" to work? The modules that are already loaded will stay referenced and used. – Bergi Feb 20 '14 at 21:17
  • It's a module, doesn't a module support being de-referenced or cleared.. – Shai UI Feb 20 '14 at 21:20
  • It could be possible by reloading the cache server file. But I never did it, just saw that was possible, but so far I never see any module doing it. I just read some discussions about it. It's possible do to it in Ruby, Rails recompile automatically the cache in development mode. It's the same process in Node.js but... DOn't know any library that does that. – Vadorequest Feb 20 '14 at 21:53
  • @foreyez: You could empty the module cache so that modules are re-loaded when `require()`d again. However, their old instances will stay in memory as long as they're referenced/used. – Bergi Feb 20 '14 at 21:55

1 Answers1

2

You cannot load code in in real-time because of the complications you would get (for example memory leaks), But in theory you should be able to do this with modules.

You could have a look at this: livenode, It is not recommended to use in production environment though

GiveMeAllYourCats
  • 860
  • 18
  • 23
  • 1
    Thanks for the link! I was looking for something like that. Of course it's not to use in production, it's better to use forever in production ;) – Vadorequest Feb 20 '14 at 21:56