Restart Kraft without ending running steps
The server restarts, the steps it was running carry on, and
kraft view list --all --status=active lists the items again. Steps of items
that run in place are the exception: pause
those items first.
A restart leaves local steps running
Stopping Kraft leaves the steps it runs on this machine for worktree items
running. That holds for Ctrl-C on a foreground kraft, kraft admin stop,
kraft admin restart, kraft admin update --restart within a major version,
and a stop or restart of the
service. The steps
belong to the local worker,
a process of its own, and it keeps running. When Kraft starts again it picks
the steps up and the items carry on.
Until then nothing answers a step's permission prompts or enforces its time
cap and idle limit. A step that asks for a decision waits, and one that
finishes meanwhile is read when Kraft is back. kraft admin stop says how
many steps it leaves running, and kraft admin stop --now stops them.
Two things still end a step:
- An item that runs in place. Its step runs in your own checkout, so a stop
ends it. When Kraft starts again the item stops with
reattach: running session, PID identity unconfirmed, no result (pid N is not alive)and the board shows it as failed.kraft item retry IDis all it needs. kraft admin stop --now. It stops every local step, and each of those items stops the same way when Kraft is back.
A step on another machine keeps running there too, and the server reconnects to it when it starts again. An update to a new major version ends no step: it waits until nothing is running. See Update when Kraft is free.
kraft admin restart lists the in-place items first and, in a terminal, asks
before going on (-y skips the question). With none, it asks nothing.
kraft admin stop only lists them.
A stop that finds a git rebase under way undoes it before the server exits,
which can take over a minute with a slow checkout filter. kraft admin stop
and kraft admin restart then print still stopping: a git rebase is being undone and wait for it instead of giving up at 15 seconds. The service's
stop timeout (TimeoutStopSec, ExitTimeOut) allows for it too: reinstall
the service to get the new value.
The worker after a stop
Added in 2.4
The worker ends on its own a few seconds after Kraft is gone and nothing runs.
Each installed Kraft has a worker of its own: after an update within a major
version the new server starts a new one and takes over the running steps,
while the old worker finishes the processes it started and exits.
kraft admin uninstall-service says if a worker is still finishing its steps.
Under a systemd service the worker starts in a scope of its own, outside the
unit's cgroup, so stopping the unit doesn't end it. Its output goes to
run/logs/local-worker.log.
Restart without ending an agent
To restart without ending the step of an item that runs in place, restart when nothing is running, or pause the running items first and resume them afterwards:
- List the active items, and note the ones that run in place:
kraft view list --all --status=active
The table doesn't mark them:kraft view show IDsaysin_place: yes, and each row of--jsonhasin_place.kraft admin restartalso names them before it asks. - Pause each in-place one:
kraft item pause ID. - Restart the server:
kraft admin restart, orkraft admin update --restartwhen you are also updating. Updating from 1.4 is the exception: use neitherupdatenorupdate --restart.kraft admin updateruns in the release you have installed, so it would run 1.4'supdate --restart, which neither lists the running items nor asks. Follow Update from 1.4 instead.kraft admin restartstops the server and starts it again. For a server started with--detach, it prints:kraft: stopped (pid 48213) kraft: http://127.0.0.1:8765 (pid 48390, detached - kraft admin stop)
When Kraft runs as a service, it printskraft: restarted the service. A server running in a terminal only stops: it printskraft: was running attached to a terminal - start it again there: kraftand exits 1. - Resume each item you paused:
kraft item resume ID.
Restart when nothing is running
Added in 2.3
To restart without pausing anything, ask for the restart at the next free moment:
kraft admin restart --when-free
Kraft restarts once no agent session runs and no item is active, waiting, queued or rate_limited, inside any allowed hours. It needs a running server, and a service or a server started with --detach: a server started in a terminal can't restart itself. Update when Kraft is free has the whole picture.
Check it worked
kraft view list --all --status=active lists the items you resumed.
Next steps
- Environment variables: the variables that locate an instance.
- Server verbs: every
kraft admincommand and its flags. - Troubleshooting: why an item stopped, and what to do.
Put a proxy in front of Kraft
Serve the board behind a reverse proxy you run, or let a proxy on this machine pass webhooks and scripts to a loopback-bound Kraft, and check that nobody gets in without signing in.
Back up and restore the database
Back up Kraft's database while the server runs, check the backup, restore it, find the copy Kraft makes before an upgrade and roll back to an earlier 2.x release.