diff --git a/nix/workbench/backend/supervisor-conf.nix b/nix/workbench/backend/supervisor-conf.nix index c07ec9b4b3f..e5e23f6f0fd 100644 --- a/nix/workbench/backend/supervisor-conf.nix +++ b/nix/workbench/backend/supervisor-conf.nix @@ -14,15 +14,13 @@ let # may run in the most unexpected places where we can't asume what is or isn't # included in $PATH. Just make sure pkgs.bashInteractive is in the nix store. sh = "${pkgs.bashInteractive}/bin/sh"; - # Same as above for `sh` applies for pkgs.coreutils. - touch = "${pkgs.coreutils}/bin/touch"; # We can't obtain the exit codes using `supervisorctl status`, it returns zero # when RUNNING and non-zero for STOPPED, EXITED, FATAL, and UNKNOWN, so as we # are not using any "autorestart" like functionality supervisord programs are # echoing their exit code after the script to a file named `exit_code` that is - # created empty just before starting the script. + # created and/or emptied before every script run. # Warning: This command assumes the "directory" is set correctly. - command = "${sh} -c \"${touch} ./exit_code; ./start.sh; echo \"$?\" > ./exit_code\""; + command = "${sh} -c \":> ./exit_code; ./start.sh; echo \"$?\" > ./exit_code\""; ## ## supervisorConf :: SupervisorConf ## diff --git a/nix/workbench/service/healthcheck.nix b/nix/workbench/service/healthcheck.nix new file mode 100644 index 00000000000..049289c8cb6 --- /dev/null +++ b/nix/workbench/service/healthcheck.nix @@ -0,0 +1,41 @@ +{ pkgs +, runJq +, backend +, profile +, nodeSpecs +}: + +with pkgs.lib; + +let + ## + ## generator-service :: (TracerConfig, NixosServiceConfig, Config, StartScript) + ## + healthcheck-service = + (nodeSpecs: + let + bashInteractive = pkgs.bashInteractive; + coreutils = pkgs.coreutils; + supervisor = pkgs.supervisor; + in { + startupScript = rec { + JSON = pkgs.writeScript "startup-healthcheck.sh" value; + value = '' + #!${bashInteractive}/bin/sh + + # Store the entrypoint env vars for debugging purposes + ${coreutils}/bin/env > /local/healthcheck.env + + # Only needed for "exec" ? + if test "''${TASK_DRIVER}" = "exec" + then + cd "''${TASK_WORKDIR}" + fi + + sleep 100000 + ''; + }; + }) + nodeSpecs.value; +in + { inherit healthcheck-service; }