ptkl kiln
Lease and work with Kiln machines from the command line: save a machine, start it for a number of minutes, push code, run commands, read logs and files, and manage jobs.
Kiln is in beta
Commands and flags may still change. Concepts (states, sizes, run identity, limits) are on the Kiln pages; this page is the command reference.
Common options
Every command that calls the API takes --env. The output options (-f, -o, --template) belong to commands that print a result. exec, logs and terminal print the machine's own output, so they take --env and the options in their own tables only.
| Option | Description |
|---|---|
--env <dev\|live> |
The environment of the API call (default: PROJECT_ENV, else dev) |
-f, --format <format> |
json, yaml, table, jsonpath or template |
-o, --output <file> |
Write the output to a file |
--template <template> |
Template for jsonpath or template formats |
--env is not --project-env
--env is where the call goes. --project-env is the project env the machine works in.
<uuid> is a machine's id. A job is addressed by <ref>, its name or id.
Machines
| Command | Purpose |
|---|---|
machines list |
List the project's machines (--deleted includes deleted ones) |
machines get <uuid> |
Show one machine |
create [-- command...] |
Save a machine and, unless --no-start, start it |
start <uuid> [-- command...] |
Start a saved machine |
stop <uuid> |
Stop the main process (--force kills it at once) |
extend <uuid> <minutes> |
Buy more minutes for the lease |
end-lease <uuid> |
End the lease now: the main process is stopped and the unused minutes come back (credits first, then GiB-hours; the shortest lease is 5 minutes). Stop alone does not end a lease |
delete <uuid> |
Give the machine back now (unused minutes come back) |
machines update <uuid> |
Set or clear the default code (--media, --to, --no-media) or change the env (--env-var, --env-file, --global-env, --keep-env) |
usage |
GiB-hours used and left this month, and the limits |
ptkl kiln machines list -f table
ptkl kiln machines get 7b0c1e52-...
ptkl kiln extend 7b0c1e52-... 30
ptkl kiln stop 7b0c1e52-...
ptkl kiln usage
ptkl kiln create
A machine is only a definition. Code and minutes come with each start, so create takes --minutes unless you pass --no-start.
| Option | Description |
|---|---|
-n, --name <name> |
Machine name |
-m, --minutes <n> |
Minutes it runs (required unless --no-start) |
-s, --size <mib> |
Memory in MiB, 128 to 4096 (the tier sets the largest) |
--disk <gib> |
Disk in GiB |
-i, --image <image> |
Image name |
--step <line> |
A start sequence shell line, run in order (repeatable) |
--cwd <dir> |
Working directory of the start sequence |
-e, --env-var <NAME[=VALUE]> |
Environment variable. The machine keeps the value encrypted and never shows it again; needs secrets::write protokol-kiln. A start without a value for it uses it (repeatable). NAME alone takes the value from your own environment |
--env-file <file> |
Read NAME=VALUE lines from a file, kept like --env-var (repeatable). Blank lines and # comments are skipped |
--global-env <NAME=KEY> |
Variable NAME from the project's global env KEY, read when the machine starts (repeatable) |
--egress <mode>, --extra-host <host> |
Network policy; extra allowed host (repeatable) |
--media <path> |
Copy a Media path in when it starts (repeatable) |
--archive <file.tar.gz\|dir> |
A .tar.gz, or a directory to pack, unpacked when it starts |
--to <folder> |
Folder for --media and --archive (default: the start directory) |
--run-as <identity> |
Run identity: prn:role:<uuid>, prn:role:maintainer, prn:api-user:<uuid> or prn:forge:<uuid> |
--project-env <dev\|live> |
Project env of the lease |
--end-on-exit |
End the lease when the main process exits; unused minutes come back |
--no-start |
Only save the definition |
# save and start for 20 minutes, with the command after --
ptkl kiln create --name build --minutes 20 --size 1024 -- npm test
# save only; start it later
ptkl kiln create --name nightly --no-start --step "npm ci" --step "npm run build"
ptkl kiln start
Runs the machine's saved sequence, or a new one for this start (--step lines, or a command after --).
| Option | Description |
|---|---|
-m, --minutes <n> |
Minutes to lease; needed when the machine is saved |
--step <line> |
New start sequence line (repeatable) |
--cwd <dir> |
Working directory |
-e, --env-var <NAME[=VALUE]> |
Environment variable for this start only: it overrides the machine's kept value of that name and is not kept (repeatable). NAME alone takes the value from your own environment |
--env-file <file> |
NAME=VALUE lines for this start only |
--global-env <NAME=KEY> |
Variable from the project's global env (repeatable) |
--media <path>, --archive <file.tar.gz\|dir>, --to <folder> |
Code to put in before it runs, see Start with code |
--no-code |
Bring no code with this start, not even the machine's default code |
--end-on-exit |
End the lease when the main process exits; unused minutes come back |
--project-env <dev\|live> |
Project env of the lease (a machine with time left keeps its lease's) |
--files-first |
Lease and copy the code in, but do not run yet |
ptkl kiln start 7b0c1e52-... --minutes 15
ptkl kiln start 7b0c1e52-... --minutes 15 -- node build.js --prod
Global env variables
--global-env NAME=KEY gives the machine a variable NAME with the value of the project's global env KEY. Give the key only, not its group. The value is read when the machine starts, and the run identity must be allowed to read it. It works the same on create, start and on jobs. For a secret, a global env key is the better way: the value never passes through your terminal. --env-var on a job (or on create and machines update) keeps a custom value encrypted with it. Give a secret as --env-var NAME, with no =: the value is read from your shell's environment, so it never sits on the command line or in your shell history. --env-file <file> does the same from a file of NAME=VALUE lines; --keep-env NAME on jobs update and machines update keeps the value already held. Env is replaced as a whole when any env flag is given, so a value you leave out is removed.
A variable is given once: by --env-var (or --env-file), --global-env or --keep-env, not by two of them.
export DB_PASSWORD=...
ptkl kiln start 7b0c1e52-... --minutes 10 --env-var DB_PASSWORD -- node migrate.js
The project env of a lease
A lease is for one project env, dev or live. --project-env on create, start and jobs create|update sets it (default dev). The machine's PROJECT_ENV and token follow it. See The env of a lease.
Code and files
| Command | Purpose |
|---|---|
push <dir> <uuid> |
Pack a directory (.gitignore respected) and unpack it in a running machine (--to <path>) |
files list <uuid> [path] |
List a directory (--depth <n>) |
files get <uuid> <path> |
Print a file, or save it with --out <file> |
files put <uuid> <path> |
Write a file from --from <file> or stdin (--mode <octal>) |
ptkl kiln push ./app 7b0c1e52-... --to /work
ptkl kiln files list 7b0c1e52-... /work --depth 2
ptkl kiln files get 7b0c1e52-... /work/report.txt --out report.txt
echo "hello" | ptkl kiln files put 7b0c1e52-... /work/hello.txt --mode 0644
These need a running machine. Details are in Commands, files and logs.
Start with code
Code comes with each start, so you can give it to create or start instead of pushing it afterwards:
--media <path>copies a Media path in (repeatable).--archive <file.tar.gz|dir>unpacks a.tar.gz, or packs and unpacks a directory.--to <folder>is where they go (default: the start directory).
See Code comes with each start.
Put files in first, run later
start --files-first leases the machine and copies the code in, but does not run the sequence. Upload more with push or files put, then start again to run.
ptkl kiln start 7b0c1e52-... --minutes 20 --media data/input --files-first
ptkl kiln files put 7b0c1e52-... /work/config.json --from config.json
ptkl kiln start 7b0c1e52-... -- node run.js
--files-first is not needed with --archive, which is uploaded before the machine runs anyway.
Commands and logs
| Command | Purpose |
|---|---|
exec <uuid> -- command... |
Run a command in a running machine and print its output |
terminal <uuid> |
Open an interactive shell in a running machine, in this terminal |
logs <uuid> |
Print the machine's log |
status <uuid> |
Show memory, swap and disk used of their limits, out-of-memory kills and uptime |
ps <uuid> |
List the processes in a running machine, busiest first |
exec options: --cwd <dir>, --user <user>, -e, --env-var <NAME[=VALUE]> and --env-file <file> (repeatable), --timeout <sec> (up to 900), and --detach to return at once with the output going to the log.
logs options: -f, --follow streams new lines until the machine ends; --since <time> shows lines since an RFC 3339 time.
ptkl kiln exec 7b0c1e52-... --cwd /work -- ls -la
ptkl kiln exec 7b0c1e52-... --detach -- ./long-task.sh
ptkl kiln logs 7b0c1e52-... --follow
Status and processes
status and ps need a running machine. Both print the time left on standard error, and -f json prints the API's response instead of the text.
state running
memory 512 MiB of 2 GiB
swap 0 B of 1 GiB
disk 1 GiB of 10 GiB
oom kills 0
uptime 2m05s
ps starts with a line for the machine's total CPU and memory, then one row per process: PID, USER, CPU%, MEM (resident), STATE, TIME (how long it has run) and COMMAND, cut to the width of the terminal. CPU% is sampled over about a second and 100 means one CPU fully busy, so a process can show more than 100 when it uses several. Rows are sorted by CPU, then memory. --limit <n> sets how many rows (50 by default, at most 200). Use it to find what takes the memory or CPU, for example after an out-of-memory exit.
CPU 93.5% MEM 1.5 GiB 2 processes
PID USER CPU% MEM STATE TIME COMMAND
42 root 93.5 1.5 GiB R 2h05m node server.js
7 app 0.0 12 KiB S 9s sh
Running ps needs machines::exec and permission to use the machine's run identity, like exec.
Terminal
ptkl kiln terminal <uuid> opens the machine's shell in your own terminal, like ssh, and exits with the shell's exit code. It needs a running machine, machines::exec and permission to use the machine's run identity. If the server stops answering for about 45 seconds, the session ends with "connection to the machine lost" and your terminal is put back as it was. See Commands, files and logs.
Jobs
Jobs are saved machine specs that run on a schedule or on request.
| Command | Purpose |
|---|---|
jobs list |
List the project's jobs |
jobs get <ref> |
Show one job |
jobs create [-- command...] |
Save a job |
jobs update <ref> [-- command...] |
Change a job; flags left out keep their value |
jobs delete <ref> |
Delete a job and its schedule |
jobs run <ref> |
Start a run now |
jobs runs <ref> |
List a job's runs |
jobs run-get <ref> <run> |
Show one run |
jobs create and jobs update take:
| Option | Description |
|---|---|
--name <name> |
Job name (update: --rename <name>) |
-m, --minutes <n> |
Optional cap in minutes for each run. Left out, a run lasts until its command finishes (at most 24 hours); unused minutes come back either way |
--schedule <cron> |
5-field cron expression; empty text means run on request only |
--timezone <zone> |
Time zone of the schedule (UTC if omitted) |
--overlap <skip\|parallel\|queue> |
What to do when a run is due while one is going |
-s, --size <mib>, --disk <gib>, -i, --image <image> |
Size, disk, image |
--step <line>, --cwd <dir> |
Start sequence and its directory |
--global-env <NAME=KEY> |
Variable from the project's global env (repeatable) |
-e, --env-var <NAME[=VALUE]>, --env-file <file> |
A custom value the job keeps encrypted and never shows again; needs secrets::write protokol-kiln (repeatable) |
--keep-env <NAME> |
update: keep the custom value the job holds for NAME |
--intake <media=to> |
Copy a Media path into the machine (repeatable) |
--egress <mode>, --extra-host <host> |
Network policy |
--run-as <identity> |
Identity every run acts as |
--project-env <dev\|live> |
Project env every run works in |
--disabled (create), --enable / --disable (update) |
Turn the schedule off or on |
A job's env is replaced as a whole when any env flag is given, so a value you leave out is removed; name each one you keep with --keep-env.
ptkl kiln jobs create --name nightly-report --schedule "0 2 * * *" --timezone Europe/Belgrade \
--minutes 15 --project-env live --global-env API_KEY=REPORT_KEY -- node report.js
ptkl kiln jobs run nightly-report
ptkl kiln jobs runs nightly-report -f table
ptkl kiln jobs update nightly-report --disable
Inside a machine
Every machine and job run has ptkl installed and signed in: no profile is needed. Its environment holds API_HOST, PROJECT_API_TOKEN (a token for the machine's run identity), PROJECT_UUID and PROJECT_ENV. ptkl picks them up as described in Without a profile, so a start sequence can run any ptkl command the identity may run.