bromanko / capemay

1 stars 0 forks source link

Auto Shutdown Tenant Apps #6

Open bromanko opened 1 year ago

bromanko commented 1 year ago

Fly machines can be suspended to not incur costs. They provide API endpoints to do so. I'll take advantage of this for any tenant apps. Fly created tired-proxy for this purpose. Rather than running another process I'll implement this directly in the server.

I'll create a singleton hosted service which starts a timer. When the timer expires it will shut down the app. This service will also provide a public method to reset the timer.

I'll create a middleware that runs before all routes. The middleware will be injected with the hosted service. Any time it's accessed it will call the method to reset the timer.