Skip to content
Snippets Groups Projects
Unverified Commit df5045e6 authored by Javier Viola's avatar Javier Viola Committed by GitHub
Browse files

fix(orchestrator): wrapper stderr redirection (#176)

Fix typo :)
parent aa55f109
Branches
No related merge requests found
Pipeline #449354 passed with stage
in 16 minutes and 56 seconds
......@@ -51,20 +51,36 @@ child_pid=""
# get the command to exec
CMD=($@)
# File to store CMD (and update from there)
ZOMBIE_CMD_FILE=/cfg/zombie.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
echo "COMMAND TO RUN IS: $CMD"
start() {
# redirect the output to be expored to loki
"${CMD[@]}" >> /proc/1/fd/1 2 >> /proc/1/fd/2 &
child_pid="$!"
# store pid
$ECHO ${child_pid} > /cfg/zombie.pid
# check if the process is running
if ! $LS /proc/$child_pid > /dev/null 2>&1 ; then
exit 1
"${CMD[@]}" >> /proc/1/fd/1 2>> /proc/1/fd/2 &
if [[ "$CMD" != "cat" ]]; then
child_pid="$!"
$ECHO $(cat $ZOMBIE_CMD_FILE)
# store pid
$ECHO ${child_pid} > /cfg/zombie.pid
# check if the process is running
if ! $LS /proc/$child_pid > /dev/null 2>&1 ; then
echo "child process doesn't exist, quiting...";
exit 1;
else
echo "PID: $child_pid alive";
fi;
else
echo "PID not stored, since was 'cat'";
fi;
}
restart() {
......@@ -96,9 +112,9 @@ resume() {
# keep listening from the pipe
while read line <$pipe
do
if [[ "$line" == 'start' ]]; then
if [[ "$line" == "start" ]]; then
start
elif [[ "$line" == 'quit' ]]; then
elif [[ "$line" == "quit" ]]; then
break
elif [[ "$line" =~ "restart" ]]; then
# check if we have timeout between restart
......@@ -114,9 +130,4 @@ do
fi
done
# exit
if [ ! -z "${child_pid}" ]; then
$KILL -9 "$child_pid"
fi
exit 0
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment