Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic solution for file changes => reload #333

Closed
PhilWaldmann opened this issue Feb 26, 2014 · 4 comments
Closed

generic solution for file changes => reload #333

PhilWaldmann opened this issue Feb 26, 2014 · 4 comments

Comments

@PhilWaldmann
Copy link
Contributor

Hi,

currently AH reloads itself if any action, task or initializer file was changed.
Are there any plans to support other files as well? e.g. model definition files for an ORM?

There are generic solutions e.g. nodemon for server reloading. What was the reason to reimplement it into actionhero?

@evantahler
Copy link
Member

As you mention, nodemon (and others) are a great tool to restart your application upon changes, and you can use it with actionhero if you want nodemon ./node_modules/.bin/actionhero start

actionhero's development mode is a little different, in that it tries hard not to restart the server process. Changes to routes, tasks, and actions can simply replace those in memory when they are updated on disk. Other changes, like changes to config.js or initializers are more severe, and will restart the whole application (much like nodemon).

Being that actionhero supports persistent connections, it is important to not disconnect the clients whenever possible (which is very likley to happen if the server was to restart).

@evantahler
Copy link
Member

If you are looking for a generic way within actionhero to watch for a file and reload, you can do that like this:

api.watchFileAndAct(path_to_file, function(){
  api.log(rebooting due to config change: ' + path_to_file, 'info');
  delete require.cache[require.resolve(path_to_file)];
  api.commands.restart.call(api._self);
});

@evantahler
Copy link
Member

some updates: evantahler@ec9d61f

and a wiki entry: evantahler@74ac033

@PhilWaldmann
Copy link
Contributor Author

Thank you very much for this detailed answer!

Keep up the great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants