Forums

How to restart the webapp server whenever the files are edited.

I currently have to edit a file, then hit <kbd>Control</kbd>+<kbd>S</kbd> (even though I'm on a Mac), then click the little refresh button. This is a bit clunky.

Is there a way to setup a watcher script that can restart the server whenever one of the files in ~/site is edited?

That is not trivial because of the way the files are over the network (linux inotify may not work).

Also in most use cases, you would not want that- ie. if your site was live and lots of users were using it, if you make a small change with a syntax error and reflexively save, you might break the site for all your users.

Behind the scenes, the webapp reload also does a bunch of stuff- it needs to reload gracefully, so it first responds to all web requests that it is processing, while juggling (redirecting) any new incoming requests, and then starts up new workers to handle the incoming requests etc, so that your customers don't see any errors when you reload. (therefore it may be a bit expensive to automatically trigger on each file save)