Skip to content

Add runit-native 'gdk status' backend

What does this merge request do and why?

Currently, we invoke sv directly when trying to get the statuses of all services with gdk status. This is inefficient for two reasons:

  1. we need to call an external program (sv), which introduces latency, and
  2. we need to parse the output of sv, which is intended for human readers.

To allievate that, this introduces a more native backend of gdk status that skips calling sv and instead parses the service status (which is written by the runit supervisor) directly from the disk.

In numbers, we are saving over 300ms with this new backend:

  • Before: ~350ms
  • After: <2ms

The new backend is also less lines of more readable code because we don't need to deal with ugly, half-arsed string parsing (like I implemented previously) and can just read the binary data directly.

This also opens up other programmatic use of checking a service status, such as cheaply checking if a service is up in e.g. a diagnostic:

is_vite_up = Runit.status(['vite']).any?(&:up?)

Before and after

image

We're no longer showing the PID but that's fine because the process is no longer running.

How to set up and validate locally

  1. Run gdk status
  2. See that the status is the same result as on the default branch

Impacted categories

The following categories relate to this merge request:

Merge request checklist

  • This MR references an issue describing the change.
  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise an issue to follow-up.
  • Documentation added/updated, if needed.
  • Announcement added, if change is notable.
  • gdk doctor test added, if needed.
Edited by Kev Kloss

Merge request reports

Loading