Skip to main content

Module service

Module service 

Source
Expand description

The background service: stopping the containers QCode started once no QCode is open.

Four parts, each usable on its own:

  • stop is the work itself: read the list of QCode’s containers, stop the ones that run, keep listed what could not be stopped.
  • Open is what every running QCode holds for its whole life: a shared lock on instances.lock beside the list. Closing it is where the last QCode to close does the work itself, so containers are stopped on a normal exit even with no service installed.
  • reaper is what qcode reaper runs: it waits in the kernel for the exclusive lock on the same file, which it gets only once no QCode holds it, however the last one went.
  • units makes the systemd and launchd files that run qcode reaper when the list changes, and the steps that install and remove them.

The lock is the kernel’s (flock), so a QCode that crashes or is killed holds nothing and keeps nobody waiting. Windows has no such lock for QCode: there every call answers io::ErrorKind::Unsupported, nothing is held and nothing is stopped.

Modules§

stop
Stopping the containers no QCode owns any more.
units
The files that install the background service, and the steps that put them in place or take them away.

Structs§

Engines
How the containers are reached: engine_for finds the engine of a kind, run runs one command and answers what it printed. The real ones are crate::engine::detect and crate::engine::run::capture; a test passes its own.
Open
A running QCode, as the other QCodes and the service see it: a shared lock on the lock file, held for as long as this value lives.
Places
Where the list of QCode’s containers and the lock of the open QCodes are kept.

Constants§

LOCK_FILE
The name of the file every open QCode holds a shared lock on, beside the list.

Functions§

reaper
What qcode reaper does: waits until no QCode is open, stops the listed containers if the setting says to, empties the list, and writes to out what it did.
report
What a reaper run has to say about reaped, one line each, in the language in force.
translator
The text of qcode reaper, in the language the person chose in QCode or else the machine’s.