Expand description
The journal on disk: one file per attempt the agent started and the master hasn’t acknowledged, so a restarted agent still reports a result it had and stops a task process its previous incarnation left behind (see archive/PROJECT.md, Worker lifecycle).
-
Files:
<journal_dir>/<attempt_id>.json, each replaced atomically (a temporary file, fsync, rename, fsync of the directory) before the message it backs is sent:runningbeforeStarted(and again with the process’s identity once it is spawned),finishedbeforeFinished. A file goes when the master acknowledges the result or decides to forget the attempt. -
On start: temporary files left by a crash are removed, finished results are reported again, and the process groups of attempts that were running are stopped (SIGTERM, then SIGKILL after a grace time); those attempts aren’t reported, so the master ends them
lost. -
Process identity: a process group ID and the start time of its leader (from
/proc/<pid>/stat), so a recycled PID isn’t taken for the task. Without/procthe agent warns once and nothing is stopped; once the leader is gone, nothing is stopped. -
Cleanups: an attempt of a task with a cleanup also keeps
<attempt_id>.attempt, what its cleanup needs to run after a restart (the assignment and where its code is), written beforeStarted, and<attempt_id>.handles, its handles, a line each, on disk before the task hears they are registered. Its record iscleaningfrom the task’s end, with the task’s result: the cleanup runs again from there (see archive/PROJECT.md, Per-task cleanup). -
One agent per journal: it holds a lock (see
Journal::lock).
Its operations block (fsync); the agent runs them off its event loop.
Structs§
- Journal
- The journal directory.
- Kept
Attempt - What a task’s cleanup needs to run after an agent restart.
- Orphan
Waits - How an orphan is waited for.
- Process
Identity - What identifies a task’s process group across an agent restart.
Enums§
- Journal
Record - What the journal knows about an attempt.
- Orphan
- How stopping an orphaned process group went.
Constants§
- LOCK_
FILE - The lock file: one agent per journal.
Functions§
- process_
identity - The identity of the process group led by
pid. - stop_
orphan - Stops the process group
identitynames, if its leader still runs: SIGTERM, and SIGKILL if the group hasn’t ended aftergrace, then waits for it to go (at most 5 s).