Skip to main content

Engine configuration

The Coflux engine is distributed as a single executable, for Linux and macOS, and as a Docker image. It can be started using the CLI or directly with Docker.

Starting the engine​

coflux engine

The first time, the CLI downloads the engine matching its version, and keeps it in the user cache directory. Workers launched by the process launcher run on the same machine. Use --docker to run the engine in Docker instead.

Options​

FlagDefaultDescription
--projectdefaultRestrict the engine to a single project
--public-host(none)Public-facing host (use % prefix for subdomain routing)
--port7777Port to run the engine on
--data-dir./dataDirectory for persistent data
--no-authfalseDisable authentication
--super-token or --super-token-hash(none)Set a super token (plain text or pre-hashed SHA-256 hex)
--secret(none)Engine secret, for signing service tokens and encrypting secrets
--team(none)Team IDs allowed for Studio auth (repeatable)
--launcher(none)Allowed launcher types (repeatable: docker, process, kubernetes, ecs, lambda)
--dockerfalseRun the engine in Docker
--image(auto)Docker image to use (implies --docker)
--binary(downloaded)Engine executable to run

These can also be set in the [engine] section of coflux.toml (e.g., port, data_dir, super_token), or with COFLUX_ENGINE_* environment variables (e.g., COFLUX_ENGINE_PORT). The command used to be coflux server, with a [server] section and COFLUX_SERVER_* variables. Those still work for now, with a warning.

Projects​

The engine can operate in two modes:

Single-project mode​

By default, the engine runs in single-project mode with a project called "default". Use --project to choose a different name:

coflux engine --project myproject

All requests are routed to this project regardless of the hostname used to connect, so workers and Studio just use the engine's address (e.g., localhost:7777).

Multi-project mode​

Configure COFLUX_PUBLIC_HOST with a % placeholder to enable subdomain-based routing, where the project is extracted from the subdomain:

docker run \
-e COFLUX_PUBLIC_HOST=%.localhost:7777 \
ghcr.io/bitroot/coflux

Workers and Studio connect using the project as a subdomain (e.g., myproject.localhost:7777). The host is the only way to choose a project: for the CLI, set it with --host or host in coflux.toml.

Environment variables​

The engine is configured via environment variables. When using coflux engine, CLI flags are mapped to these variables automatically.

VariableDefaultDescription
PORT7777Port to listen on
COFLUX_PROJECTdefaultRestrict to a single project (none when COFLUX_PUBLIC_HOST starts with %)
COFLUX_PUBLIC_HOSTlocalhost:PORTPublic host (use % prefix for subdomain routing)
COFLUX_REQUIRE_AUTHtrueWhether authentication is required
COFLUX_SUPER_TOKEN_HASH(none)SHA-256 hex hash of the super token
COFLUX_SECRET(none)Engine secret, for signing service tokens and encrypting secrets
COFLUX_STUDIO_TEAMS(none)Comma-separated team IDs for Studio auth
COFLUX_STUDIO_URLhttps://studio.coflux.comStudio URL
COFLUX_DATA_DIR./dataData directory path
COFLUX_ALLOW_ORIGINShttps://studio.coflux.comComma-separated CORS origins
COFLUX_LAUNCHER_TYPES(none)Allowed launcher types (e.g., docker,process,kubernetes,ecs,lambda)
COFLUX_CLI_PATHcofluxCLI binary path for process launcher
COFLUX_TELEMETRY_RETENTION_DAYS30How long logs and metrics are kept (0 keeps them indefinitely)
COFLUX_ARCHIVE_THRESHOLD6 GBDatabase size, in bytes, beyond which settled runs are archived
COFLUX_HOLD(none)Puts every project on hold, for this reason (a word, such as maintenance)
COFLUX_MAX_RUN_STEPS(none)The most steps a run may have
COFLUX_MAX_WORKERS(none)The most workers a project may have connected
COFLUX_MAX_QUEUED(none)The most executions a project may have waiting for a worker

Holds and limits​

Setting COFLUX_HOLD to a reason (a word, such as maintenance) puts every project on hold. Executions that are running carry on, and the steps they submit are accepted, but nothing is given to a worker, pools launch no workers, and new runs and re-runs are refused. Everything can still be read, and the queue shows the hold as what each waiting execution is waiting for. Starting the engine again without the setting lifts it, and what was waiting is given out. This is a way to let an engine drain before stopping it.

COFLUX_MAX_RUN_STEPS, COFLUX_MAX_WORKERS and COFLUX_MAX_QUEUED limit, for each project, how many steps a run may have, how many workers may be connected at once, and how many executions may be waiting for a worker. None is set by default. Whatever would go past a limit is refused with limit_exceeded, naming the limit: a run submitted from outside, a step submitted by an execution (which gets an error), or a worker connecting (which keeps trying, less and less often). A worker that still has executions running is always let back in.

Data storage​

The engine stores data in the configured data directory. Each project has a directory under projects/, holding an SQLite database for orchestration (including service tokens and secrets) and another for logs and metrics. Blobs are stored under blobs/, shared between projects.

To keep a project's database from growing without bound, once it passes COFLUX_ARCHIVE_THRESHOLD, its oldest settled runs are moved into the project's archive/ directory. Archived runs are still served from there, and a run is brought back if one of its steps is re-run.

Upgrading from 0.12​

The first time the engine starts on a data directory from 0.12, it migrates each project before serving it: workspaces, manifests, pools, service tokens, run history, and the logs and metrics within the retention period. This happens automatically. The engine doesn't accept connections until it's done, which for a large project can take a while, so allow for it in any health check. If the engine is stopped part way, it starts the migration again next time.

The old files are left where they are, unchanged, so you can go back to 0.12 with them. Anything done since on the new engine won't be there, though, and work that was in progress may run again. Going forward again doesn't migrate a second time: the engine carries on from its own data, without whatever was done in 0.12 meanwhile. Once you're happy with the upgrade, you can delete the old files: orchestration.sqlite, admin.sqlite, logs.sqlite and metrics.sqlite, and the orchestration/, logs/ and metrics/ directories, in each project's directory.

Work that was in progress carries on. Executions that hadn't started are queued again, still waiting for whatever they were waiting for. Ones a worker was running are treated as abandoned once their session times out, and retried if their retry settings allow. Any that 0.12 left unfinished in an older epoch, where it no longer scheduled them, are marked as abandoned. Workers that 0.12 launched for pools aren't managed by the new engine, so stop any that are still running.