Add run_process() to start services without screen
* USE_SCREEN defaults to True, set it to False to exec the services
directly via bash. SCREEN_DEV is still supported until the CI
scripts get updated.
* The extra logging file descriptors are properly closed in the child process
and stdout/stderr are redirected to the log files.
* The screen_rc() call is still present; this means that stack-screenrc will
have a complete record of what was started and rejoin-stack.sh may be able
to re-create the setup under screen.
* The python interpreter was unwilling to write to the log files without
unbufering stdout by using PYTHONUNBUFFERED. This feels hackish and should
be investigated further.
Change-Id: I012ed049f2c8b185a2e6929d73edc29e167bc21f
diff --git a/stack.sh b/stack.sh
index a4106e5..3fab488 100755
--- a/stack.sh
+++ b/stack.sh
@@ -824,8 +824,17 @@
# Configure screen
# ----------------
-if [ -z "$SCREEN_HARDSTATUS" ]; then
- SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
+USE_SCREEN=$(trueorfalse True $USE_SCREEN)
+if [[ "$USE_SCREEN" == "True" ]]; then
+ # Create a new named screen to run processes in
+ screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash
+ sleep 1
+
+ # Set a reasonable status bar
+ if [ -z "$SCREEN_HARDSTATUS" ]; then
+ SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
+ fi
+ screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"
fi
# Clear screen rc file
@@ -834,12 +843,6 @@
echo -n > $SCREENRC
fi
-# Create a new named screen to run processes in
-screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash
-sleep 1
-
-# Set a reasonable status bar
-screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"
# Initialize the directory for service status check
init_service_check