CTRLctrl docs

App lifecycle

This page covers what you can do with an app once it's deployed: redeploy it, roll it back, resize it, run it in high availability mode, and delete it.

Stop and start#

Stopping and starting an app from the dashboard, the API or the CLI is coming soon.

An app can still end up stopped, for example when a restart fails after a volume change. A stopped app holds none of your blocks. A redeploy starts it again, and needs room in your blocks to do so.

Redeploy#

A redeploy runs your app again with its current environment variables. A Git app is rebuilt from its branch, and an image app re-pulls its image. Use it from CI after you push a new image.

Pushing to the connected branch redeploys a Git app on its own. See Deploy from GitHub.

With the CLI#

ctrl deploy my-api

The CLI prints redeployed: true, or redeployed: false with the error.

With the API#

curl -X POST -H "Authorization: Bearer $CTRL_API_KEY" \
  https://api.getctrl.dev/v1/apps/my-api/redeploy
{ "ok": true, "redeployed": true, "deploy_id": "new-deploy-uuid" }

When it fails, the body has "redeployed": false and an error:

Status Why
400 GitHub not connected -- cannot rebuild from source (Git apps), or no image reference stored for this app
402 Your subscription has lapsed, or a stopped app doesn't fit your blocks
409 A node the app runs on can't take the deploy
502 The deploy or its routing failed
503 node not found

Saving environment variables also redeploys the app.

Deploy history#

The deploys tab lists every deploy, newest first. Each one shows its commit, its trigger (such as push or rollback), its status, how long it took and when it started.

curl -H "Authorization: Bearer $CTRL_API_KEY" \
  https://api.getctrl.dev/v1/apps/my-api/deploys

Each deploy has id, commit_sha, commit_msg, trigger, status, duration_ms, error, created_at and finished_at.

Roll back#

A rollback deploys the commit of an earlier successful deploy again. It only works for Git apps, and only for a deploy with a recorded commit.

An image app can't roll back: deploy history records no image. Redeploy the image tag you want instead. See Deploy an image.

In the dashboard#

Open the deploys tab. Every earlier successful deploy with a commit has a Roll back button. Confirm, and the app restarts on that commit's build. The rollback shows in the list as a new deploy, with the trigger rollback.

With the CLI#

ctrl rollback my-api

With no options, this rolls back to the newest successful deploy whose commit differs from the latest successful deploy's. To pick one, pass its id:

ctrl rollback my-api --to <deploy-id>

With the API#

curl -X POST -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"deploy_id": "deploy-uuid"}' \
  https://api.getctrl.dev/v1/apps/my-api/rollback
{ "ok": true, "deploy_id": "new-deploy-uuid" }
Status Why
400 An image app, cannot rollback -- no commit SHA recorded, or GitHub not connected
402 Your subscription has lapsed, or a stopped app doesn't fit your blocks
404 app not found or deploy not found
409 A node the app runs on can't take it, or its agent is too old to build a pinned commit
502 rollback failed: ...

Resize#

You buy capacity in blocks. One block is 1 vCPU, 2 GB RAM and 30 GB storage for $5 a month. Your apps share your blocks, and each app gets exactly its size: it never bursts past it.

Sizes#

The dashboard offers four presets:

Size Blocks vCPU Memory Disk
XS ⅙ 0.15 320 MB 5 GB
S ½ 0.5 1 GB 15 GB
M 1 1 2 GB 30 GB
L 2 2 4 GB 60 GB

You can also set a custom size:

  • CPU: at least 0.1 vCPU, in steps of 0.05.
  • Memory: at least 256 MB.
  • Disk: at least 5120 MB.

An app uses as many blocks as its largest share of one block. For example, 0.5 vCPU with 2 GB of memory uses 1 block.

One app can't be bigger than all the blocks you own. Together your apps' sizes may add up to more than your blocks: what they really use is capped at your blocks.

In the dashboard#

Open the settings tab and use the ctrl resources panel. Pick a preset or type a custom size, then press save size. The panel tells you how many blocks the size uses and how many you have left.

  • A running app restarts at the new size.
  • A stopped app keeps the size for its next start.

With the API#

Send any of cpu_millis (thousandths of a vCPU), vcpu_count (whole vCPUs), mem_size_mb and disk_size_mb. Fields you leave out keep their current value.

curl -X PATCH -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cpu_millis": 500, "mem_size_mb": 1024}' \
  https://api.getctrl.dev/v1/apps/my-api/resources
{ "ok": true, "redeployed": true, "vcpu_count": 1, "cpu_millis": 500, "mem_size_mb": 1024, "disk_size_mb": 15360 }
Status Why
400 cpu_millis must be at least 100 (0.1 vCPU), in steps of 50, mem_size_mb must be at least 256, or disk_size_mb must be at least 5120
402 The size is bigger than all your blocks, or your subscription has lapsed
409 <node> has no room for this size: try a smaller one, or the app's first deploy is still running
502 The restart failed; the old size stays

High availability#

High availability runs a second copy of your app on another node in the same region. Both copies take requests, so if one fails, the other keeps serving.

Before you turn it on, know that:

  • It uses twice your app's size against your blocks.
  • Anything kept in memory, like sessions or caches, isn't shared between the copies.
  • Scheduled jobs inside your app run twice.
  • Deploys roll out one copy at a time.

You can't turn it on when:

  • The app isn't running.
  • The app has a volume. See Volumes.
  • The app has a database. See Databases.
  • The app is a preview.
  • Two copies would be bigger than all your blocks.
  • No other node in the region has room for a second copy.

In the dashboard#

Open the settings tab and flip the high availability switch in the ctrl ha panel. If it can't be turned on, the panel says why. The panel lists each copy's node and whether it's reachable.

Turning it off stops the copy on the other node. If your app's node then fails, the app is down until it's replaced.

The logs panel gets a copy picker, so you can read each copy's logs. See Logs and metrics.

With the API#

curl -X PATCH -H "Authorization: Bearer $CTRL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"enabled": true}' \
  https://api.getctrl.dev/v1/apps/my-api/ha
{ "ok": true, "enabled": true, "copies": ["us-1", "us-2"] }

GET /v1/apps/:app_id shows the app's copies, and ha_blocked says why high availability can't be turned on, or is null when it can.

Delete#

Deleting an app stops it, on every node it runs on, and permanently removes:

  • the app and its MicroVM,
  • its routing and its getctrl.dev address,
  • its deploy history,
  • its custom domains, including their hostnames at Cloudflare.

This can't be undone.

Volumes#

An app with a volume can't be deleted. Its data never goes with it. Delete the volume first, or detach it to keep the data. See Volumes.

Databases#

Deleting an app doesn't delete its database. Delete the database first if you don't want to keep it. See Databases.

In the dashboard#

Open the settings tab and press delete app in the danger zone. Confirm with Delete app.

With the API#

curl -X DELETE -H "Authorization: Bearer $CTRL_API_KEY" \
  https://api.getctrl.dev/v1/apps/my-api
{ "ok": true }

While the app has a volume, you get 409:

{ "error": "this app has volume uploads (10240 MB): delete the volume first, or keep the app", "volume_id": "vol-..." }

You also get 409 while the app's first deploy is still running.