Open crisward opened 1 year ago
Hi @crisward, thank you for opening up this issue.
There currently doesn't exist any mechanism to disable the autostart feature; however, I don't think it's unreasonable of a request to ask for.
I would like to figure out the best way possible to define this mechanism and I was thinking to start with a global configuration variable. Turning this variable on for the whole setup, it will disable the autostart feature when anyone tries to access a proxy that isn't running it will return a 502. How does this sound and does it fit your use case?
I am open to accepting pull requests if you would like to look into it and have time! If not, I'll add it to my backlog 😄
Had a quick look at this. It looks like each request goes via the steps of
group.exists
-> group.start
-> group.proxy
In the following places
/src/daemon/vhosts/tld.js
/src/daemon/routers/index.js
/src/daemon/routers/api/servers.js
/src/daemon/group.js
Seems to hold the Group class, so we could modify the start
method to throw if a config option is set of autostart === false
However it looks like the servers.js
code gets hit when you flick the switch inside the chalet dashboard. We'd still want that to work. So we'd want to only trigger for the 2 other routes.
tld.js
seems to be trigger when going to a custom prefix domainrouters/index.js
seems to be triggered when going to the default chalet url +/[project_name]
Not 100% sure of the best way of doing this.
It feels like we could create another method / middleware on group and use that to decide if we should start or not. This could check the config and throw an next(err) if autostart is false.
Sound reasonable?
First, thanks for maintaining this tool. Been using hotel for years and your battle against code rot is very much appreciated.
I expose my chalet setup via a reverse proxy, so clients can see work in progress. However I sometimes find they've restarted their dev site just by going to the provided domain. I obviously want to keep my dev machine running as few sites as possible, so it'd be good to disable this behaviour.
Is this something you would implement, or accept a pull request for? (unless this is already possible, but I missed it from the docs).
Thanks.