Skip to content

file

kind: file
name: server_config
spec:
path: config/local.toml
content: |
[ai]
openai_api_key = "${ secret.openai }"
anthropic_api_key = "${ secret.anthropic }"
[files]
provider = "local"
---
kind: process
name: server
needs: ["${ file.server_config }"]
spec:
cmd: ./server

The daemon renders content like any spec string and writes the result to path. A secret in content is its placeholder everywhere runy shows the spec (runy get, the console, the state database), and the value is swapped in only when the file is written. Add the file’s path to .gitignore: the file on disk holds the values.

field default
path the file, relative to the workspace root, absolute, or under ~ (your home folder). Missing parent folders are created, readable by you alone required
content the text to write; it may be empty required
mode the file’s permission bits as an octal string, such as "0644"; quote it, since YAML reads a bare 0600 as a number "0600"

The file is written when the resource starts, when its rendered spec changes and on the restart signal. It waits, Pending, until every secret it reads has a value, so the file never holds a placeholder for a secret that is still resolving. When a secret’s value changes, its placeholder changes, the spec renders differently and the file is written again.

A write goes to a temporary file in the same folder, which gets the mode before any content and is renamed over path, so a reader never sees half a file. A file that already has the content and the mode is left alone.

runy never overwrites or deletes a file it did not write. It remembers a keyed hash of what it wrote (in its state database, never the content), and when the resource is applied it looks at what is at path:

at path what happens
nothing the file is written
the file runy wrote, unchanged since it is replaced
a file that already has the content to write it is taken over, and nothing is written
any other file an Error: `<path>` exists and was not written by runy; remove it or point `path` elsewhere

There is no setting that forces an overwrite. Remove the file, or point path elsewhere, and send restart. A path that is a directory or a symbolic link (which runy does not follow), or that lies in the workspace’s cache folder or runy’s state folder, is an Error too.

what happens to the resource the file
its document is removed (runy delete, an edited resource file, runy unload) deleted, if it is unchanged since runy wrote it; a file someone changed is left, and the journal says so
it goes idle (runy stop, a disabled namespace) kept; deleted later if the document is removed while it is idle
the daemon stops, restarts or upgrades kept; the next daemon finds it by its hash and does not write it again when the content is the same, and deletes it if the document was removed meanwhile
its workspace is removed with runy workspace rm --purge deleted, if it is unchanged, also when the workspace is not running; a file left is named in the command’s warnings
path changes the new file is written, then the old one is deleted under the same rule

A file is deleted only when it is a regular file with the content runy wrote; a symbolic link at its path is not followed and is left. Folders it created are never removed.

{ "path": "/Users/me/app/config/local.toml", "revision": "5c1e9a07" }
field
path the absolute path. ${ file.<name> } reads it, the file’s default value, so needs: ["${ file.<name> }"] waits until the file is written
revision eight hex digits that change with the written content; a keyed hash, so it does not reveal a short value

A process reading the path keeps running when the file is rewritten. One that reads its config only at start should restart when the content changes: put the revision in its spec, for instance in an env value.

kind: process
name: server
spec:
cmd: ./server
env:
CONFIG: ${ file.server_config }
CONFIG_REVISION: ${ file.server_config.status.revision }

There is no status while the file is not written (the resource is Pending or in Error), so its readers wait.

The resource’s journal has wrote <path> (<n> bytes, mode 0600), kept <path>: unchanged, adopted <path>, removed <path> and left <path>: changed since it was written, and the errors. The content is never journaled.

message cause
`<path>` exists and was not written by runy; remove it or point `path` elsewhere a file runy did not write, or one changed since runy wrote it
`<path>` is a symbolic link, which runy does not follow a link at path
`<path>` is a directory a directory at path
`<path>` is inside runy's own folder a path in the workspace’s cache folder or the state folder
`mode` must be octal permission bits a mode such as "rw" or one above "0777"
content: the secret `<namespace>/<name>` has no value of this revision the secret stopped or changed while the file was written; nothing was written
signal
restart checks the file and writes it again, under the same rule: runy signal file/server_config restart

The kind works the same in a VM’s own workspace. A secret the file reads there gets its value from the host when the vm grants it with resource: true; Secrets in machines has an example.