Recurring work
Applies to: Rubian builds that include daemon commands
Updated
Recurring work runs an operation repeatedly under a name. A persistent definition can be restored in the configured Rubian environment. This guide applies only to builds with the daemon command family and an authenticated workspace that supports persistence.
Create a small recurring operation#
The following example increments a value retained between successful runs:
daemon('counter-example', every: 5, code: '(daemon_previous || 0) + 1')
daemon_status('counter-example')
Wait several seconds and inspect the status again. The tick count and result should advance. This example demonstrates user-authored recurring work; it does not modify a service or contact another machine.
Stop the example and disable restoration when finished:
daemon_stop('counter-example', disable: true)
Configuration and context#
| Argument or value | Meaning |
|---|---|
name |
A name of 1–64 characters. Start with a letter or digit; subsequent characters may also include _, . and -. |
every: |
Delay in seconds between the end of one iteration and the next. Defaults to 5.0; must be at least 0.05. This is not an exact wall-clock schedule. |
code: |
Ruby source for the operation. Required when persist: true, the default. |
persist: |
Whether to retain a restorable definition. Set false for a session-only example. |
daemon_name |
The name available inside the supplied code. |
daemon_tick |
The iteration number available inside the supplied code. |
daemon_previous |
The previously retained successful result, or nil before one exists. |
Keep results small and composed of simple values such as strings, numbers, arrays and hashes. Avoid returning live connections, handles or objects whose meaning depends on the current session.
Stop, disable and enable#
daemon_stop(name) stops the running instance. Its default does not disable an existing persistent definition. Use daemon_stop(name, disable: true) when the work must remain disabled after the environment restores recurring work.
daemon_enable(name) enables and starts an existing persistent definition. It reports an error if no definition exists. Starting a daemon again with the same name replaces its active instance; review the supplied code before doing so.
daemon_status(name, quiet: true) returns the retained status without printing the normal summary. It includes the most recent iteration information, retained result and error, together with the current job when available. A last-known result does not establish that the operation is still running.
Investigate a failure#
An iteration can record an error and continue to the next iteration. Review the error and tick count together; a growing tick count alone does not establish successful work. Stop a failing operation before changing its definition if another attempt could repeat a harmful action.
If checkpoints cannot be saved or the authenticated home is unavailable, resolve workspace access before relying on restoration. Restoration also depends on the supplied environment being configured to perform it. Use your evaluation runbook for startup and recovery; do not infer restart behavior from a single successful session.