Any way to make container sleep during night only?
pratyaksh123
HOBBYOP

3 months ago

Can we have a way to put the container to sleep during a certain timeframe where we know it won't be used as frequently? But also maintain responsiveness during the high frequeency parts of the day, where I find that the cold boot time is kind of high, when clients on mobile are trying to sign in , I want my backend to be up during the day.

Solved$10 Bounty

9 Replies

Railway
BOT

3 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


pratyaksh123
HOBBYOP

3 months ago

Can I write a script to do this myself, does your API support it ?


3 months ago

I don't think Railway supports this directly, but you could set up a script that just pings the server evert few minutes (~9 minutes) until night time or whenever, you could even make it a cron job that starts in the morning and self terminates at night. The cost would be negligible if done over the private network.


pratyaksh123
HOBBYOP

3 months ago

yes I got it , for anyone else looking to do it , just make this graphQL mutation environmentPatchCommit to toggle the sleep

{
  "commitMessage": "enable sleep",
  "environmentId": "yourenvID",
  "patch": {
    "services": {
      "YourServiceId": {
        "deploy": {
          "sleepApplication": false
        }
      }
    }
  }
}

With the details of your service and can easily write a cron script to do so.


3 months ago

Would this not redeploy your service (or require a redeploy) twice a day then though?


pratyaksh123
HOBBYOP

3 months ago

yes that is fine


pratyaksh123
HOBBYOP

3 months ago

Or do you think this will be less cost efficient?


3 months ago

Toggling sleep does not put your app to sleep instantly, for what it's worth.


Status changed to Awaiting User Response Railway 3 months ago


pratyaksh123
HOBBYOP

3 months ago

Yeah its fine, currently the sleep time is kind of less , and ideally i would want a config parameter in settings where i can adjust the sleep time.


Status changed to Awaiting Railway Response Railway 3 months ago


Status changed to Solved brody 3 months ago


Loading...