cross.stream / docs
GitHub Discord

Determine why a process stopped

Every exit emits a topic that names the reason. You don't need to inspect meta to know what happened:

TopicWhat it meansWill it restart?
xs.<kind>.<name>.fin.termUser appended termNo
xs.<kind>.<name>.fin.okSelf-terminated cleanly (actor returned no next; service script exited and isn't auto-restarting)No
xs.<kind>.<name>.fin.errorRuntime crash, or it fell behind the live stream (meta.message says which)No
xs.<kind>.<name>.invalidScript failed to parse at create time (never started)No (and the previous good version is kept as the fallback)
xs.<kind>.<name>.replacedA newer create displaced itA new instance is starting now
xs.<kind>.<name>.stoppedxs is shutting down (xs.stopping)Yes, when xs starts back up

Quick recipes

"Did this service crash or did I stop it?"

.cat -T xs.service.api.* | where topic =~ "fin\\." | last 1

If you see fin.error, the script crashed; the meta.message field has the error text. A message of fell behind the live stream: N frames skipped means the script was slower than the frames arriving on its read; see What a follow delivers.

If you see fin.term, you (or some other appender) asked for the stop.

"Why isn't my service running after a restart?"

.cat -T xs.service.api.* | last 5

Look for the most recent terminal frame:

"Was a process replaced, or did it crash and a successor was registered separately?"

Related