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

Prevent Sites Autostart on domain visit #41

Open
crisward opened this issue Mar 2, 2023 · 2 comments
Open

Prevent Sites Autostart on domain visit #41

crisward opened this issue Mar 2, 2023 · 2 comments

Comments

@crisward
Copy link

crisward commented Mar 2, 2023

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.

@jeansaad
Copy link
Owner

jeansaad commented Mar 2, 2023

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 😄

@crisward
Copy link
Author

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 domain
  • routers/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?

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