← Blog

Services can now run at set hours

Give a service the hours it should run, such as weekdays from 9 to 7: it starts by itself, stops when they close, and nothing wakes it in between.

A development server that never slept

Until today a service on Estiba ran in one of two ways. A website or a game server slept after 5 minutes without visits or players and woke with the next one, or it stayed always on.

Sleeping works well for an app people visit now and then. It works badly for anything with a public address, because the internet is never quiet. Bots, scanners and link checkers knock on every domain at all hours. A staging site that nobody looks at after 7 in the evening still gets requests through the night, so it rarely goes 5 minutes without one and hardly sleeps, and you pay for it all night.

Bots had the opposite problem. A Discord or Telegram bot has no domain or port to visit, so it never slept at all. If you only wanted it online during your community's events, you had to ask your agent to stop it and start it again by hand.

So there is now a third choice. A service can run only at the hours you give it.

How set hours work

You give each day of the week its own hours, in your time zone. A day can have up to four stretches, so a shop's split day of 9 to 2 and 4 to 7 is fine. A day you leave out stays closed. A stretch can also run past midnight: 22:00 to 02:00 on Friday closes at 2 on Saturday morning, and 00:00 to 00:00 is the whole day.

When the hours open, the service starts by itself, with no deployment. When they close, Estiba stops it within a minute. While it is closed:

  • Nothing wakes it. A visit to its domain gets an answer saying it is closed and until when; a connection to its ports wakes nothing either.
  • It costs only what its volume holds, like a sleeping service. Memory and CPU are not charged.
  • A deployment still runs, so you can check a new version works at 11 at night. Once that is done the service goes back to sleep.

Set hours apply to any kind of service: a website, a game server on ports or a bot with neither. And while they are open the service runs whether or not anyone visits, so a web with set hours does not also sleep for lack of visits in the middle of the afternoon.

Asking your agent

You don't need to write the hours down in any format. Tell your agent what you want, in your own words:

Run my staging site only on weekdays from 9 to 7, Madrid time.
Keep the Minecraft server on from 6 pm to midnight on weekdays, and all day on Saturday and Sunday.

The agent turns that into a schedule and saves it with update_service, or with create_service for a new app. To go back to sleeping or always on, ask it to remove the hours.

The When it runs setting of a service, with At set hours chosen and its hours summed up under it

In the dashboard, a service's When it runs has a third option, At set hours, next to sleeping and always on. Bots get it too. The hours are set in a popup, one row per day, and once saved they are summed up under the choice, so you can see at a glance when it runs. While the service is closed, the dashboard shows it asleep and says until when.

The hours popup, with weekdays open from 9 to 7 and the weekend closed

What it does to the bill

On Estiba you pay for the memory and CPU an app uses while it runs, plus what its volume holds. Set hours cut the first part to the hours you choose.

Weekdays from 9 to 7 are 50 hours out of the week's 168, so a service on those hours pays about 30 % of what the same service costs always on, plus its volume. You also know the share in advance. With sleeping, how long an app sleeps depends on its visits, and a public site with bots on it may hardly sleep at all. With set hours the share is fixed: the service runs for the hours you gave it, no more.

The dashboard's Billing shows what each service used each day, so you can check the difference after a week.

Underneath

A schedule is a small object on the service: a time zone with an IANA name, such as Europe/Madrid, and the days that open, each with its stretches in that zone. If you use the API yourself, this is what weekdays from 9 to 7 look like:

{
  "schedule": {
    "timezone": "Europe/Madrid",
    "hours": {
      "mon": [{ "start": "09:00", "end": "19:00" }],
      "tue": [{ "start": "09:00", "end": "19:00" }],
      "wed": [{ "start": "09:00", "end": "19:00" }],
      "thu": [{ "start": "09:00", "end": "19:00" }],
      "fri": [{ "start": "09:00", "end": "19:00" }]
    }
  }
}

An empty {} removes the hours. Estiba checks the schedule when you save it and refuses two stretches of a day that overlap or touch, which should be one, naming the day.

Nothing about whether a service is open is stored anywhere. Once a minute, the server that runs it works out from the clock and the schedule alone whether it should be running. That means a server that restarts, or another one that takes the service over after a failure, reaches the same answer without being told. When a schedule opens, each service starts at its own moment within the first minute, so a server with many services on the same hours does not start them all in the same second.

Try it

Tell your agent which app should run and when, for example: "Run my staging site on weekdays from 9 to 7, my time." The details of sleeping, always on and set hours are in Deploy an app, and what each one costs is in Credit and prices.

Ask your AI about Estiba

It opens with the question already written. We left a summary just for it, so it answers right and spends few tokens.