Skip to content

Keep a service running

Always-on is available on api.tori.host for plans that include it. A control plane that does not offer it shows no switch in the console, the CLI and the MCP tool say it is not available there, and PUT /api/apps/{slug}/always-on answers 404 with always_on_unavailable.

A service app takes naps: after a while with no requests it scales to zero, and the next request waits a few seconds for an instance to start. Always-on keeps one instance running instead, so that request does not wait. Static sites are served from their files, never wait to start, and cannot be always-on.

Your plan includes a number of always-on apps. The number is in the plan comparison on the pricing page, under Settings → Billing in the console, in npx tori.host whoami, and in limits.alwaysOnApps of GET /api/plans. Some plans include none.

Switching on one app more than the plan includes is refused with always_on_plan_limit, and nothing changes. After a move to a plan that includes fewer, the apps asked for first keep their places and the rest are asked for, not held: they sleep when idle as before, and keep their place in line. When a place frees up (you switch another app off or delete it, or move to a plan that includes more), the next app in line is kept running without being asked again.

Always-on is part of the plan’s price. Nothing is metered or billed by use.

In the console, open a service app. On its overview tab, the Always-on section says whether the app is kept running, asked for, or sleeps when idle. Keep it running switches it on; Let it sleep switches it off. On a plan that includes none, the section links to Upgrade instead.

With the CLI, the word first and the app after it, so an app named on or off is never taken for the switch:

Terminal window
npx tori.host always-on # show the state of the app in ./tori.json
npx tori.host always-on on # keep it running
npx tori.host always-on off my-app # let a named app sleep again
npx tori.host always-on status my-app

Add --json for { "requested": …, "granted": …, "warm": …, "inEffect": …, "state": … }; state is one of on, switching-on, awaiting-deploy, switching-off, releasing, held and off, the same reading the console and the MCP tool give. warm is null, and state is granted, from a control plane that does not report whether the zone serves the warm revision. See tori always-on.

From a coding agent, the MCP tool tori_always_on reads the state, or sets it with enabled. See the MCP guide.

Over HTTP, PUT /api/apps/{slug}/always-on with { "enabled": true } or { "enabled": false }. The answer is the app, with alwaysOn.requested (you asked), alwaysOn.granted (it holds now) and alwaysOn.warm (the zone serves the warm revision). Asking again for what is already set answers the same.

The switch changes what Tori asks the zone for at once: alwaysOn.granted is that decision. The zone follows within about a minute, as a new revision of the same image and environment, and once it serves that revision the app reports alwaysOn.warm: true. Only then does the console say kept running (until then, switching on), npx tori.host always-on say “one instance kept running”, and --json and tori_always_on report inEffect: true. instances.wanted is not the sign: it is 1 for any app that is busy at the moment, warm or not. If it stays switching on, the new revision may not be starting: check the app’s logs. Switching off works the same way in reverse: until the zone serves the new revision, the app still has warm: true, the console says letting it sleep, and it keeps its instance; after that it scales to zero once nobody is visiting.

When always-on is granted and the app has no live deploy yet, the console says awaiting a live deploy. Deploys started while always-on is granted start warm. If a first deploy was already in progress when you switched on, it can go live with its original settings and still sleep when idle. The console then shows switching on while Tori rolls out its warm replacement.

Always-on removes the wait after an idle period, not every wait. An always-on app still has no instance for a while during a deploy, when the node it runs on restarts, or when its instance fails and is started again.

An app keeps its place in line, but is not kept running, while:

  • after a move to a plan that includes fewer, the places are held by apps that asked first;
  • the account has a payment to settle (see Billing): always-on is released at once, even while the apps are still served, and comes back when the payment is settled;
  • Tori has disabled the app or the account, or the account is suspended.

Switching it off is possible whatever the plan, an unpaid payment, or Tori having disabled the app. An account Tori has disabled cannot sign in at all, so it cannot switch anything.

A refusal changes nothing: the app keeps sleeping when idle.

  • always_on_plan_limit: the plan’s places are all asked for by other apps. Switch one of them off, or move to a plan that includes more.
  • always_on_no_capacity: the region has no room for another always-on app right now. Switching on is checked against a share of the region’s capacity, so that always-on apps cannot leave the sleeping apps of other customers nowhere to wake. The check is made when an app is switched on: an app that already holds its place keeps it. Try again later.
  • always_on_not_eligible: the account has a payment to settle, or the app or the account is disabled.
  • always_on_static_app: the app is a static site.

When an always-on app is deleted, disabled or suspended, its room in the region is freed only once the region confirms that its instance is gone, which can take a few minutes. A switch-on in that window may get always_on_no_capacity and succeed when you try again a little later.

When an app with a live deploy regains its grant after it or its account is re-enabled, or after a billing suspension ends, the console shows switching on until the zone confirms that the warm revision is serving again. The zone checks that the warm revision has a ready instance and verifies HTTPS at the platform address and any configured primary redirect. To check an additional custom domain, see its status on the app’s Domains tab. If an app already has a live deploy when it is re-enabled and a candidate’s release command is still running, Tori can restore the previous live revision while the release command continues. The new deploy takes over after its release command succeeds and its revision is ready.