Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(orchestrator): store cmd as file and add fn to read and update c… #1579

Merged
merged 4 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
...
}: let
# this change on each change of dependencies, unfortunately this hash not yet automatically updated from SRI of package.lock
npmDepsHash = "sha256-crUfrJrTjkKpt2AUL8/E1pa4XoZZorme3ZZocccs2bM=";
npmDepsHash = "sha256-DI22Ywb0ZWIZAnfjqpkGbA0T0g3MbsvdtoI1OeeXLjQ=";
####

# there is officia polkadot on nixpkgs, but it has no local rococo wasm to run
Expand Down
19 changes: 18 additions & 1 deletion javascript/packages/orchestrator/zombie-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ if [ -f /cfg/coreutils ]; then
LS="/cfg/coreutils ls"
KILL="/cfg/coreutils kill"
SLEEP="/cfg/coreutils sleep"
ECHO="/cfg/coreutils echo"
CAT="/cfg/coreutils cat"
else
RM="rm"
MKFIFO="mkfifo"
MKNOD="mknod"
LS="ls"
KILL="kill"
SLEEP="sleep"
CAT="cat"
fi


Expand Down Expand Up @@ -44,6 +47,8 @@ child_pid=""
# get the command to exec
CMD=($@)

# File to store CMD (and update from there)
ZOMBIE_CMD_FILE=/cfg/zombie.cmd
restart() {
if [ ! -z "${child_pid}" ]; then
$KILL -9 "$child_pid"
Expand Down Expand Up @@ -71,6 +76,16 @@ resume() {
fi
}

# update start cmd by reading /cfg/zombie.cmd
update_zombie_cmd() {
NEW_CMD=$($CAT $ZOMBIE_CMD_FILE)
CMD=($NEW_CMD)
}

# Store the cmd and make it available to later usage
# NOTE: echo without new line to allow to customize the cmd later
$ECHO -n "${CMD[@]}" > $ZOMBIE_CMD_FILE

# Exec the command and get the child pid
"${CMD[@]}" &
child_pid="$!"
Expand All @@ -83,7 +98,7 @@ fi;
# keep listening from the pipe
while read line <$pipe
do
if [[ "$line" == 'quit' ]]; then
if [[ "$line" == "quit" ]]; then
break
elif [[ "$line" =~ "restart" ]]; then
# check if we have timeout between restart
Expand All @@ -96,6 +111,8 @@ do
pause
elif [[ "$line" == "resume" ]]; then
resume
elif [[ "$line" == "update-cmd" ]]; then
update_zombie_cmd
fi
done

Expand Down
Loading