Re: machine api to supervise

From: e-mail j.deboynepollard-newsgroups <j.deboynepollard-newsgroups_at_ntlworld.com>
Date: Thu, 24 Sep 2015 11:56:40 +0100 (BST)

Buck Evan:
> Is there any simple machine-friendly interface to the same information?
> Surely I'm not meant to read supervise/state directly?

* http://homepage.ntlworld.com./jonathan.deboynepollard/Softwares/nosh.html
* https://github.com/fmoo/python-supervise

There's nothing wrong with reading the control/status API information directly.
 As I point out on the nosh blurb, the likes of Peter Ruibal and Andrés
J. Díaz do, in their Python library.  The status API has been stable and
backwards compatible for almost 20 years, with the daemontools-encore
extensions preserving backwards compatibility.  Unless some daemontools-family
developer goes and does something wrongheaded like breaking compatibility, a lot
of existing similar tools and libraries can cope with all of runit,
daemontools, daemontools-encore, nosh, and so forth.

There is something wrong with processing the output of svstat, and you are
right to be leery of doing so. The daemontools manual explicitly states that it
is human readable, rather than machine-readable. And there are variations in the
human-readable forms, which are fine for humans but no good for programs.  Back
in 2013, Jos Backus discussed with me having a tool that would produce
machine-readable output. So I made svshow, which is part of the nosh toolset.
 It produces output in either .INI format or as JSON. I did mention this, on
this very mailing list, only last month.

M. Backus preferred the JSON.  It does things like splitting up the array of
services dependencies and orderings automatically as part of the JSON decoding
itself.  Whereas in the .INI format one still has to word-split and
dequote things like the After= line, which is actually a sequence of quoted
C-escaped whitespace-separated strings.

Here it is, probably line wrapped to death by this mail UI, running on a FreeBSD
system:

JdeBP ~ %svshow --json /var/sv/polkitd /var/sv/dbus
{
 "/var/sv/polkitd":{
"DaemontoolsState":"up","DaemontoolsEncoreState":"running","MainPID":559,"Timestamp":4611686019870343363,"UTCTimestamp":1442955423,"Want":"nothing","Paused":false,"Preset":true,"RemainAfterExit":false,"Wants":["/etc/service-bundles/targets/basic"],"Before":["/etc/service-bundles/targets/shutdown"],"After":["../dbus","/etc/service-bundles/targets/extra-shared-libraries","/etc/service-bundles/targets/basic","/etc/service-bundles/targets/local-syslog"],"Conflicts":[],"Required-By":[],"Wanted-By":["/etc/service-bundles/targets/workstation"],"Stopped-By":["/etc/service-bundles/targets/shutdown"],"LogService":"../cyclog_at_polkitd"}
,"/var/sv/dbus":{
"DaemontoolsState":"up","DaemontoolsEncoreState":"running","MainPID":531,"Timestamp":4611686019870343362,"UTCTimestamp":1442955422,"Want":"nothing","Paused":false,"Preset":true,"RemainAfterExit":false,"Wants":["/etc/service-bundles/targets/basic"],"Before":["/etc/service-bundles/targets/shutdown"],"After":["../machine-id","/etc/service-bundles/targets/extra-shared-libraries","/etc/service-bundles/targets/basic"],"Conflicts":[],"Required-By":[],"Wanted-By":["/etc/service-bundles/targets/workstation","/etc/service-bundles/targets/sockets"],"Stopped-By":["/etc/service-bundles/targets/shutdown"],"LogService":"../cyclog_at_dbus"}
}
JdeBP ~ %svshow /var/sv/moused
[/var/sv/moused]
DaemontoolsState=up
DaemontoolsEncoreState=running
MainPID=520
Timestamp=4611686019870343362
UTCTimestamp=1442955422
Want=nothing
Paused=no
Preset=yes
RemainAfterExit=no
Wants=/etc/service-bundles/targets/basic
Before=/etc/service-bundles/targets/shutdown
After=/etc/service-bundles/targets/basic
Conflicts=
Required-By=
Wanted-By=/etc/service-bundles/targets/workstation
Stopped-By=/etc/service-bundles/targets/shutdown
LogService=../cyclog_at_moused

JdeBP ~ %
Received on Thu Sep 24 2015 - 10:56:40 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC