Services and types

A service’s kind is what the API stores. It is one of server, worker, cron, static or database. The product types map onto it:

Product typekindPublic address
Web serviceserverYes, when enabled
Private serviceserverNo
WorkerworkerNo
Static sitestaticYes, when enabled
Cron jobcronNo
Database servicedatabaseNo (use connection)

There is no web or private kind. The CLI and both SDKs take type: web or type: private, and store kind: server. A private service is a server service with no public address.

Source

A service builds from one source.

source.typeWhat it needsNotes
gitref (repository URL), optional branch and root_dirBuilt on a Services build cell
imageref (OCI image), optional port, optional registry_secretThe image is run as-is
uploadupload_idPUT a .tar.gz, .tar.zst, .tar or .zip archive first
forgerefA repository hosted by MIOSA Forge

Dockerfile builds run on the Services build cells and are detected in the source. While the build cells are off, a Dockerfile service does not build; use a git build or an image source.

Uploading a directory is one command:

miosa service deploy shop API --dir . --wait

The CLI packs the directory (skipping .git, node_modules and .env*), records the archive with POST /uploads, PUTs it to the returned URL and deploys {source: {type: "upload", upload_id}}. Archives are single use and expire after an hour.

Settings

Settings are validated strictly: an unknown key is refused, so a typo never silently stays.

SettingApplies toMeaning
start_commandallReplaces the image entrypoint when a replica starts.
pre_deploy_commandallRuns once in the new replica before the app starts. A non-zero exit fails the release.
healthcheck_pathserverThe path probed before a new release becomes active.
healthcheck_timeout_sserverHow long a release may take to pass.
restart_policyallalways, on_failure or never.
max_retriesallRestarts before an on_failure replica is left stopped.
replicasall1 to 50. A writable volume forces 1.
regionallus-west, us-east or us-mia.
limitsall{vcpu, memory_mb}. Above 4 vCPU or 8192 MB the release fails.
sleepservices with a public address{enabled, idle_s}. The next request wakes the service.
cron_schedulecronRequired. Five-field cron, UTC.
overlap_sallExtra time before the previous release is stopped.
terminate_grace_sallExtra time before the previous release is stopped, like overlap_s.
volumesserver, workerUp to four {volume, mount_path, read_only}.

Read what each setting actually does on your platform:

miosa service settings shop

Each entry is enforced (it takes effect), stored (kept but not applied yet) or unsupported. Never present a stored setting as if it took effect.

Create and change

miosa service create shop API --type web --repo https://github.com/acme/api --replicas 2
miosa service update shop API --replicas 4
miosa service scale  shop API --replicas 4        # also queues a release

update merges settings: only the flags you pass change. It sends the lock_version it read; a stale value is refused with STALE_SERVICE so two editors cannot overwrite each other. scale changes replicas, region or limits and queues a release that applies them.

Cron jobs

miosa service create shop Nightly --type schedule \
  --repo https://github.com/acme/api \
  --start-command "node jobs/nightly.js" \
  --schedule "0 3 * * *"
miosa service runs shop Nightly --output

runs shows the newest 20 runs with state, exit code, times and output. A run is limited to five minutes.

Database services

A database service is a managed Postgres or Redis bound to the project. Apply a template to create one with its variables wired, or attach an existing managed database. The connection string is only available through connection, which is audited:

miosa service connection shop Postgres

Limits and errors

ErrorMeaning
SERVICE_NOT_FOUNDNo service with that id in the project. The API resolves services by id only.
STALE_SERVICEThe lock_version you sent is older than the stored one. Re-read and retry.
SERVICE_CONFLICTstart on a service that is already running or starting.
SERVICES_NOT_STOPPEDstop could not stop a replica; the service stays running.
INGRESS_DISABLEDPublic addresses are off for this platform; the service runs but has no address to reach it on.
PLAN_LIMIT_REACHEDThe plan’s service limit is reached.
Was this page helpful?