Change-Id: I9b119e2c6d4d88a67d485f61662037984c2d9b15
| ... | ... |
@@ -585,6 +585,52 @@ function restart_service() {
|
| 585 | 585 |
} |
| 586 | 586 |
|
| 587 | 587 |
|
| 588 |
+# Helper to launch a service in a named screen |
|
| 589 |
+# screen_it service "command-line" |
|
| 590 |
+function screen_it {
|
|
| 591 |
+ NL=`echo -ne '\015'` |
|
| 592 |
+ SCREEN_NAME=${SCREEN_NAME:-stack}
|
|
| 593 |
+ if is_service_enabled $1; then |
|
| 594 |
+ # Append the service to the screen rc file |
|
| 595 |
+ screen_rc "$1" "$2" |
|
| 596 |
+ |
|
| 597 |
+ screen -S $SCREEN_NAME -X screen -t $1 |
|
| 598 |
+ # sleep to allow bash to be ready to be send the command - we are |
|
| 599 |
+ # creating a new window in screen and then sends characters, so if |
|
| 600 |
+ # bash isn't running by the time we send the command, nothing happens |
|
| 601 |
+ sleep 1.5 |
|
| 602 |
+ |
|
| 603 |
+ if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 604 |
+ screen -S $SCREEN_NAME -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log
|
|
| 605 |
+ screen -S $SCREEN_NAME -p $1 -X log on |
|
| 606 |
+ ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
|
|
| 607 |
+ fi |
|
| 608 |
+ screen -S $SCREEN_NAME -p $1 -X stuff "$2$NL" |
|
| 609 |
+ fi |
|
| 610 |
+} |
|
| 611 |
+ |
|
| 612 |
+ |
|
| 613 |
+# Screen rc file builder |
|
| 614 |
+# screen_rc service "command-line" |
|
| 615 |
+function screen_rc {
|
|
| 616 |
+ SCREEN_NAME=${SCREEN_NAME:-stack}
|
|
| 617 |
+ SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc |
|
| 618 |
+ if [[ ! -e $SCREENRC ]]; then |
|
| 619 |
+ # Name the screen session |
|
| 620 |
+ echo "sessionname $SCREEN_NAME" > $SCREENRC |
|
| 621 |
+ # Set a reasonable statusbar |
|
| 622 |
+ echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC |
|
| 623 |
+ echo "screen -t shell bash" >> $SCREENRC |
|
| 624 |
+ fi |
|
| 625 |
+ # If this service doesn't already exist in the screenrc file |
|
| 626 |
+ if ! grep $1 $SCREENRC 2>&1 > /dev/null; then |
|
| 627 |
+ NL=`echo -ne '\015'` |
|
| 628 |
+ echo "screen -t $1 bash" >> $SCREENRC |
|
| 629 |
+ echo "stuff \"$2$NL\"" >> $SCREENRC |
|
| 630 |
+ fi |
|
| 631 |
+} |
|
| 632 |
+ |
|
| 633 |
+ |
|
| 588 | 634 |
# ``pip install`` the dependencies of the package before ``setup.py develop`` |
| 589 | 635 |
# so pip and not distutils processes the dependency chain |
| 590 | 636 |
# Uses globals ``TRACK_DEPENDES``, ``*_proxy` |
| ... | ... |
@@ -134,8 +134,9 @@ if [ ! -d $FILES ]; then |
| 134 | 134 |
exit 1 |
| 135 | 135 |
fi |
| 136 | 136 |
|
| 137 |
+SCREEN_NAME=${SCREEN_NAME:-stack}
|
|
| 137 | 138 |
# Check to see if we are already running DevStack |
| 138 |
-if type -p screen >/dev/null && screen -ls | egrep -q "[0-9].stack"; then |
|
| 139 |
+if type -p screen >/dev/null && screen -ls | egrep -q "[0-9].$SCREEN_NAME"; then |
|
| 139 | 140 |
echo "You are already running a stack.sh session." |
| 140 | 141 |
echo "To rejoin this session type 'screen -x stack'." |
| 141 | 142 |
echo "To destroy this session, type './unstack.sh'." |
| ... | ... |
@@ -976,51 +977,11 @@ if [ -z "$SCREEN_HARDSTATUS" ]; then |
| 976 | 976 |
SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
|
| 977 | 977 |
fi |
| 978 | 978 |
|
| 979 |
-# Our screenrc file builder |
|
| 980 |
-function screen_rc {
|
|
| 981 |
- SCREENRC=$TOP_DIR/stack-screenrc |
|
| 982 |
- if [[ ! -e $SCREENRC ]]; then |
|
| 983 |
- # Name the screen session |
|
| 984 |
- echo "sessionname stack" > $SCREENRC |
|
| 985 |
- # Set a reasonable statusbar |
|
| 986 |
- echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC |
|
| 987 |
- echo "screen -t stack bash" >> $SCREENRC |
|
| 988 |
- fi |
|
| 989 |
- # If this service doesn't already exist in the screenrc file |
|
| 990 |
- if ! grep $1 $SCREENRC 2>&1 > /dev/null; then |
|
| 991 |
- NL=`echo -ne '\015'` |
|
| 992 |
- echo "screen -t $1 bash" >> $SCREENRC |
|
| 993 |
- echo "stuff \"$2$NL\"" >> $SCREENRC |
|
| 994 |
- fi |
|
| 995 |
-} |
|
| 996 |
- |
|
| 997 |
-# Our screen helper to launch a service in a hidden named screen |
|
| 998 |
-function screen_it {
|
|
| 999 |
- NL=`echo -ne '\015'` |
|
| 1000 |
- if is_service_enabled $1; then |
|
| 1001 |
- # Append the service to the screen rc file |
|
| 1002 |
- screen_rc "$1" "$2" |
|
| 1003 |
- |
|
| 1004 |
- screen -S stack -X screen -t $1 |
|
| 1005 |
- # sleep to allow bash to be ready to be send the command - we are |
|
| 1006 |
- # creating a new window in screen and then sends characters, so if |
|
| 1007 |
- # bash isn't running by the time we send the command, nothing happens |
|
| 1008 |
- sleep 1.5 |
|
| 1009 |
- |
|
| 1010 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 1011 |
- screen -S stack -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log
|
|
| 1012 |
- screen -S stack -p $1 -X log on |
|
| 1013 |
- ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
|
|
| 1014 |
- fi |
|
| 1015 |
- screen -S stack -p $1 -X stuff "$2$NL" |
|
| 1016 |
- fi |
|
| 1017 |
-} |
|
| 1018 |
- |
|
| 1019 | 979 |
# Create a new named screen to run processes in |
| 1020 |
-screen -d -m -S stack -t stack -s /bin/bash |
|
| 980 |
+screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash |
|
| 1021 | 981 |
sleep 1 |
| 1022 | 982 |
# Set a reasonable statusbar |
| 1023 |
-screen -r stack -X hardstatus alwayslastline "$SCREEN_HARDSTATUS" |
|
| 983 |
+screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS" |
|
| 1024 | 984 |
|
| 1025 | 985 |
|
| 1026 | 986 |
# Horizon |