Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
beterraba: document types and add a function to make status more friendly
beterraba/beterraba.ha | 18 ++++++++++++++++++
diff --git a/beterraba/beterraba.ha b/beterraba/beterraba.ha index 611242640bbe2c14579975170dbafbb83bc215c4..df870627ea60f958fa8afd30611fa6ce615ddf53 100644 --- a/beterraba/beterraba.ha +++ b/beterraba/beterraba.ha @@ -7,6 +7,9 @@ STARTED, CRASHED }; +// A service definition is just the parsed out contents of the service, like +// which commands to execute, what args, the working directory and it's reload, +// etc export type servdef = struct { name: str, desc: str, @@ -16,6 +19,9 @@ wd: str, reloadcmd: str }; +// A service is the actual service to be executed. It contains a [[servdef]] +// which it sources its info to be processed. A service contains a state and +// more info regarding the process itself (like PID, exit status, etc) export type service = struct { name: str, desc: str, @@ -24,4 +30,16 @@ definition: servdef, process: exec::process }; +// Maps a [[service]] status into a friendly message +export fn strstatus(s: status) const str = { + switch (s) { + case status::STARTED => + return "Started"; + case status::CRASHED => + return "Crashed"; + case status::STOPPED => + return "Stopped"; + case => + return "Unknown value"; + }; };