Skip to content

Commit

Permalink
workbench: empty the exit_code file before a supervisord program is s…
Browse files Browse the repository at this point in the history
…tarted
  • Loading branch information
fmaste committed May 26, 2023
1 parent 9ded384 commit d625a47
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
6 changes: 2 additions & 4 deletions nix/workbench/backend/supervisor-conf.nix
Expand Up @@ -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
##
Expand Down
41 changes: 41 additions & 0 deletions 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; }

0 comments on commit d625a47

Please sign in to comment.