Add runit-native 'gdk status' backend
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
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:
- we need to call an external program (
sv), which introduces latency, and - 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
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
- Run
gdk status - See that the status is the same result as on the default branch
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
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 doctortest added, if needed.
