1. Justin Sheehy
  2. webmachine
  3. Issues
Issue #1 open

reload server when dispatch.conf change

Benoit Chesneau
created an issue

Actually, you have to kill and restart the server to load changes in dispatch.conf. it would be usefull to have the server reloaded when you change the dispatch.conf file.

Comments (4)

  1. Justin Sheehy repo owner
    • changed status to open

    I worry a bit about the stability of Webmachine applications if the standard behavior were to monitor a file and to change the dispatch list whenever the file was noticed to be different. For instance, what if you saved the file in a text editor after making just some of your changes?

    The dispatch list is currently changeable at runtime, it is just not conveniently exposed. The dispatch list term is stored in the dispatch_list application environment variable. See webmachine_mochiweb for how this is used and see wmtrace_resource:add_dispatch_rule/2 for an example of modifying the dispatch list of a live Webmachine server.

    While I don't want to make the default behavior be to constantly monitor the file and auto-reload, it should not be too hard to expose a utility function that could be manually invoked to reload a dispatch.conf file.

  2. Anonymous

    Hi, Benoit. Your request reminded me of a behavior I enjoyed while using Erlyweb. If you're still looking for a solution, I have taken Justin's advice and checked a gen_server into my wmexamples repo. It's called 'dispatch_watcher', and it has a behavior something like the mochiweb reloader in that it checks priv/dispatch.conf for updates once per second, reloading when necessary (although, both the path and interval are configurable).

    Maybe a candidate for future Webmachine inclusion? (I'd advise some testing first - "Works on my machine," is all I can guarantee right now.)

  3. Benoit Chesneau reporter

    I'm agree, changing dispatching on the fly in production may be a problem. However using this feature while developping could be usefull. I will test dispatch_watcher later this afternoon. Thanks!

  4. Log in to comment