Skip to content

Daemon mode

rk daemon turns a host into a worker for Runik Control, which schedules jobs across many workers and keeps their reports. The worker connects out to Runik Control, runs one job at a time, and streams events and the report back. It keeps no state of its own between jobs.

Daemon mode needs the licence feature fleet.worker (Enterprise).

Shell

Flags

FlagDefaultWhat it does
-control <host:port>required: Runik Control's address
-token-file <path>$RK_TOKEN_FILEthe join token, its first line. rk warns if other users can read the file
-token <t>$RK_TOKENthe token on the command line; rk warns, because other users can see it in the process list
-tlsTLS with the system's trusted CAs
-ca <pem>TLS with this CA
-cert, -keymutual TLS. The certificate's CN or a DNS SAN must equal -id
-server-namethe TLS server name to verify
-insecureallow cleartext. Without it, cleartext to anything but loopback is refused
-idthe hostnamethe worker's identity
-labels k=v,...labels for scheduling. Empty, duplicate or valueless labels are an error
-drain-timeout20show long a shutdown waits for held reports to be delivered
-max-held-bytes256 MiBmemory for reports waiting to be delivered (at least 64 MiB)
-metrics-port, -metrics-addroff, 127.0.0.1Prometheus metrics (also needs obs.prometheus); see Metrics
-allow-cmd-actionsoffallow cmd actions; a job can't turn this on
-debug, -trace, -json, -logfile, -log-callerlogging

How a worker behaves

  • Capabilities. It advertises what it can run: ngap, diameter, sbi, rest, pfcp, gtpu, fuzz, suite, narrowed to what its licence grants.
  • One job at a time. A job offered while the worker is busy or draining is answered with an error.
  • Every job is checked against the licence: its protocols, environment, rate, starts and subscribers.
  • Lost connection. A job keeps running when the connection drops. Its report is held until Runik Control acknowledges it: up to 16 reports and 8 suite cycles, within -max-held-bytes. When the budget runs out, the worker trims reports first, then drops the oldest.
  • Reconnect:

    • it retries with backoff from 1s up to 30s, capped at 5s while it holds reports;
    • if Runik Control refuses the worker (bad token or certificate), it exits 1, unless it holds reports. Then it keeps trying for up to 10 minutes.

Signals

  • First SIGINT or SIGTERM: the worker drains:

    • it takes no new job and cancels the running one;
    • it waits until its held reports are delivered, or -drain-timeout passes;
    • it exits 0 after a clean drain, 1 after a timeout.
  • A second signal: it exits 1 at once.
  • SIGHUP: it re-reads the licence. A licence that doesn't load leaves the old one in place. Changed capabilities are re-announced.

Exit codes

  • 2: no -control, or a bad flag.
  • 5: the licence doesn't grant fleet.worker, or obs.prometheus when -metrics-port is set.
  • 1:

    • an unsafe transport (cleartext to a remote address without -insecure);
    • a token problem;
    • a metrics port that can't be bound;
    • a refusal from Runik Control.