Merge "Remove screen support from devstack completely"

This commit is contained in:
Jenkins 2017-09-07 13:38:03 +00:00 committed by Gerrit Code Review
commit 1ad91a7d4b
9 changed files with 16 additions and 572 deletions

View File

@ -29,7 +29,6 @@ psmisc
python2.7
python-dev
python-gdbm # needed for testr
screen
tar
tcpdump
unzip

View File

@ -24,7 +24,6 @@ psmisc
python-cmd2 # dist:opensuse-12.3
python-devel # pyOpenSSL
python-xml
screen
systemd-devel # for systemd-python
tar
tcpdump

View File

@ -28,7 +28,6 @@ psmisc
pyOpenSSL # version in pip uses too much memory
python-devel
redhat-rpm-config # missing dep for gcc hardening flags, see rhbz#1217376
screen
systemd-devel # for systemd-python
tar
tcpdump

View File

@ -1380,62 +1380,6 @@ function zypper_install {
zypper --non-interactive install --auto-agree-with-licenses "$@"
}
# Process Functions
# =================
# _run_process() is designed to be backgrounded by run_process() to simulate a
# fork. It includes the dirty work of closing extra filehandles and preparing log
# files to produce the same logs as screen_it(). The log filename is derived
# from the service name.
# Uses globals ``CURRENT_LOG_TIME``, ``LOGDIR``, ``SCREEN_LOGDIR``, ``SCREEN_NAME``, ``SERVICE_DIR``
# If an optional group is provided sg will be used to set the group of
# the command.
# _run_process service "command-line" [group]
function _run_process {
# disable tracing through the exec redirects, it's just confusing in the logs.
xtrace=$(set +o | grep xtrace)
set +o xtrace
local service=$1
local command="$2"
local group=$3
# Undo logging redirections and close the extra descriptors
exec 1>&3
exec 2>&3
exec 3>&-
exec 6>&-
local logfile="${service}.log.${CURRENT_LOG_TIME}"
local real_logfile="${LOGDIR}/${logfile}"
if [[ -n ${LOGDIR} ]]; then
exec 1>&"$real_logfile" 2>&1
bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${service}.log"
if [[ -n ${SCREEN_LOGDIR} ]]; then
# Drop the backward-compat symlink
ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${service}.log
fi
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
export PYTHONUNBUFFERED=1
fi
# reenable xtrace before we do *real* work
$xtrace
# Run under ``setsid`` to force the process to become a session and group leader.
# The pid saved can be used with pkill -g to get the entire process group.
if [[ -n "$group" ]]; then
setsid sg $group "$command" & echo $! >$SERVICE_DIR/$SCREEN_NAME/$service.pid
else
setsid $command & echo $! >$SERVICE_DIR/$SCREEN_NAME/$service.pid
fi
# Just silently exit this process
exit 0
}
function write_user_unit_file {
local service=$1
local command="$2"
@ -1535,21 +1479,6 @@ function _run_under_systemd {
$SYSTEMCTL start $systemd_service
}
# Helper to remove the ``*.failure`` files under ``$SERVICE_DIR/$SCREEN_NAME``.
# This is used for ``service_check`` when all the ``screen_it`` are called finished
# Uses globals ``SCREEN_NAME``, ``SERVICE_DIR``
# init_service_check
function init_service_check {
SCREEN_NAME=${SCREEN_NAME:-stack}
SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then
mkdir -p "$SERVICE_DIR/$SCREEN_NAME"
fi
rm -f "$SERVICE_DIR/$SCREEN_NAME"/*.failure
}
# Find out if a process exists by partial name.
# is_running name
function is_running {
@ -1576,135 +1505,11 @@ function run_process {
time_start "run_process"
if is_service_enabled $service; then
if [[ "$USE_SYSTEMD" = "True" ]]; then
_run_under_systemd "$name" "$command" "$group" "$user"
elif [[ "$USE_SCREEN" = "True" ]]; then
if [[ "$user" == "root" ]]; then
command="sudo $command"
fi
screen_process "$name" "$command" "$group"
else
# Spawn directly without screen
if [[ "$user" == "root" ]]; then
command="sudo $command"
fi
_run_process "$name" "$command" "$group" &
fi
_run_under_systemd "$name" "$command" "$group" "$user"
fi
time_stop "run_process"
}
# Helper to launch a process in a named screen
# Uses globals ``CURRENT_LOG_TIME``, ```LOGDIR``, ``SCREEN_LOGDIR``, `SCREEN_NAME``,
# ``SERVICE_DIR``, ``SCREEN_IS_LOGGING``
# screen_process name "command-line" [group]
# Run a command in a shell in a screen window, if an optional group
# is provided, use sg to set the group of the command.
function screen_process {
local name=$1
local command="$2"
local group=$3
SCREEN_NAME=${SCREEN_NAME:-stack}
SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
screen -S $SCREEN_NAME -X screen -t $name
local logfile="${name}.log.${CURRENT_LOG_TIME}"
local real_logfile="${LOGDIR}/${logfile}"
echo "LOGDIR: $LOGDIR"
echo "SCREEN_LOGDIR: $SCREEN_LOGDIR"
echo "log: $real_logfile"
if [[ -n ${LOGDIR} ]]; then
if [[ "$SCREEN_IS_LOGGING" == "True" ]]; then
screen -S $SCREEN_NAME -p $name -X logfile "$real_logfile"
screen -S $SCREEN_NAME -p $name -X log on
fi
# If logging isn't active then avoid a broken symlink
touch "$real_logfile"
bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${name}.log"
if [[ -n ${SCREEN_LOGDIR} ]]; then
# Drop the backward-compat symlink
ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${1}.log
fi
fi
# sleep to allow bash to be ready to be send the command - we are
# creating a new window in screen and then sends characters, so if
# bash isn't running by the time we send the command, nothing
# happens. This sleep was added originally to handle gate runs
# where we needed this to be at least 3 seconds to pass
# consistently on slow clouds. Now this is configurable so that we
# can determine a reasonable value for the local case which should
# be much smaller.
sleep ${SCREEN_SLEEP:-3}
NL=`echo -ne '\015'`
# This fun command does the following:
# - the passed server command is backgrounded
# - the pid of the background process is saved in the usual place
# - the server process is brought back to the foreground
# - if the server process exits prematurely the fg command errors
# and a message is written to stdout and the process failure file
#
# The pid saved can be used in stop_process() as a process group
# id to kill off all child processes
if [[ -n "$group" ]]; then
command="sg $group '$command'"
fi
# Append the process to the screen rc file
screen_rc "$name" "$command"
screen -S $SCREEN_NAME -p $name -X stuff "$command & echo \$! >$SERVICE_DIR/$SCREEN_NAME/${name}.pid; fg || echo \"$name failed to start. Exit code: \$?\" | tee \"$SERVICE_DIR/$SCREEN_NAME/${name}.failure\"$NL"
}
# Screen rc file builder
# Uses globals ``SCREEN_NAME``, ``SCREENRC``, ``SCREEN_IS_LOGGING``
# screen_rc service "command-line"
function screen_rc {
SCREEN_NAME=${SCREEN_NAME:-stack}
SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc
if [[ ! -e $SCREENRC ]]; then
# Name the screen session
echo "sessionname $SCREEN_NAME" > $SCREENRC
# Set a reasonable statusbar
echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC
# Some distributions override PROMPT_COMMAND for the screen terminal type - turn that off
echo "setenv PROMPT_COMMAND /bin/true" >> $SCREENRC
echo "screen -t shell bash" >> $SCREENRC
fi
# If this service doesn't already exist in the screenrc file
if ! grep $1 $SCREENRC 2>&1 > /dev/null; then
NL=`echo -ne '\015'`
echo "screen -t $1 bash" >> $SCREENRC
echo "stuff \"$2$NL\"" >> $SCREENRC
if [[ -n ${LOGDIR} ]] && [[ "$SCREEN_IS_LOGGING" == "True" ]]; then
echo "logfile ${LOGDIR}/${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC
echo "log on" >>$SCREENRC
fi
fi
}
# Stop a service in screen
# If a PID is available use it, kill the whole process group via TERM
# If screen is being used kill the screen window; this will catch processes
# that did not leave a PID behind
# Uses globals ``SCREEN_NAME``, ``SERVICE_DIR``
# screen_stop_service service
function screen_stop_service {
local service=$1
SCREEN_NAME=${SCREEN_NAME:-stack}
SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
if is_service_enabled $service; then
# Clean up the screen window
screen -S $SCREEN_NAME -p $service -X kill || true
fi
}
# Stop a service process
# If a PID is available use it, kill the whole process group via TERM
# If screen is being used kill the screen window; this will catch processes
@ -1724,149 +1529,27 @@ function stop_process {
$SYSTEMCTL stop devstack@$service.service
$SYSTEMCTL disable devstack@$service.service
fi
if [[ -r $SERVICE_DIR/$SCREEN_NAME/$service.pid ]]; then
pkill -g $(cat $SERVICE_DIR/$SCREEN_NAME/$service.pid)
# oslo.service tends to stop actually shutting down
# reliably in between releases because someone believes it
# is dying too early due to some inflight work they
# have. This is a tension. It happens often enough we're
# going to just account for it in devstack and assume it
# doesn't work.
#
# Set OSLO_SERVICE_WORKS=True to skip this block
if [[ -z "$OSLO_SERVICE_WORKS" ]]; then
# TODO(danms): Remove this double-kill when we have
# this fixed in all services:
# https://bugs.launchpad.net/oslo-incubator/+bug/1446583
sleep 1
# /bin/true because pkill on a non existent process returns an error
pkill -g $(cat $SERVICE_DIR/$SCREEN_NAME/$service.pid) || /bin/true
fi
rm $SERVICE_DIR/$SCREEN_NAME/$service.pid
fi
if [[ "$USE_SCREEN" = "True" ]]; then
# Clean up the screen window
screen_stop_service $service
fi
fi
}
# Helper to get the status of each running service
# Uses globals ``SCREEN_NAME``, ``SERVICE_DIR``
# service_check
# use systemctl to check service status
function service_check {
local service
local failures
SCREEN_NAME=${SCREEN_NAME:-stack}
SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
if [[ ! -d "$SERVICE_DIR/$SCREEN_NAME" ]]; then
echo "No service status directory found"
return
fi
# Check if there is any failure flag file under $SERVICE_DIR/$SCREEN_NAME
# make this -o errexit safe
failures=`ls "$SERVICE_DIR/$SCREEN_NAME"/*.failure 2>/dev/null || /bin/true`
for service in $failures; do
service=`basename $service`
service=${service%.failure}
echo "Error: Service $service is not running"
done
if [ -n "$failures" ]; then
die $LINENO "More details about the above errors can be found with screen"
fi
}
# Tail a log file in a screen if USE_SCREEN is true.
# Uses globals ``USE_SCREEN``
function tail_log {
local name=$1
local logfile=$2
if [[ "$USE_SCREEN" = "True" ]]; then
screen_process "$name" "sudo tail -f $logfile | sed -u 's/\\\\\\\\x1b/\o033/g'"
fi
}
# Deprecated Functions
# --------------------
# _old_run_process() is designed to be backgrounded by old_run_process() to simulate a
# fork. It includes the dirty work of closing extra filehandles and preparing log
# files to produce the same logs as screen_it(). The log filename is derived
# from the service name and global-and-now-misnamed ``SCREEN_LOGDIR``
# Uses globals ``CURRENT_LOG_TIME``, ``SCREEN_LOGDIR``, ``SCREEN_NAME``, ``SERVICE_DIR``
# _old_run_process service "command-line"
function _old_run_process {
local service=$1
local command="$2"
# Undo logging redirections and close the extra descriptors
exec 1>&3
exec 2>&3
exec 3>&-
exec 6>&-
if [[ -n ${SCREEN_LOGDIR} ]]; then
exec 1>&${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} 2>&1
ln -sf ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${1}.log
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
export PYTHONUNBUFFERED=1
fi
exec /bin/bash -c "$command"
die "$service exec failure: $command"
}
# old_run_process() launches a child process that closes all file descriptors and
# then exec's the passed in command. This is meant to duplicate the semantics
# of screen_it() without screen. PIDs are written to
# ``$SERVICE_DIR/$SCREEN_NAME/$service.pid`` by the spawned child process.
# old_run_process service "command-line"
function old_run_process {
local service=$1
local command="$2"
# Spawn the child process
_old_run_process "$service" "$command" &
echo $!
}
# Compatibility for existing start_XXXX() functions
# Uses global ``USE_SCREEN``
# screen_it service "command-line"
function screen_it {
if is_service_enabled $1; then
# Append the service to the screen rc file
screen_rc "$1" "$2"
if [[ "$USE_SCREEN" = "True" ]]; then
screen_process "$1" "$2"
else
# Spawn directly without screen
old_run_process "$1" "$2" >$SERVICE_DIR/$SCREEN_NAME/$1.pid
for service in ${ENABLED_SERVICES//,/ }; do
# because some things got renamed like key => keystone
if $SYSTEMCTL is-enabled devstack@$service.service; then
# no-pager is needed because otherwise status dumps to a
# pager when in interactive mode, which will stop a manual
# devstack run.
$SYSTEMCTL status devstack@$service.service --no-pager
fi
fi
done
}
# Compatibility for existing stop_XXXX() functions
# Stop a service in screen
# If a PID is available use it, kill the whole process group via TERM
# If screen is being used kill the screen window; this will catch processes
# that did not leave a PID behind
# screen_stop service
function screen_stop {
# Clean up the screen window
stop_process $1
}
function tail_log {
deprecated "With the removal of screen support, tail_log is deprecated and will be removed after Queens"
}
# Plugin Functions
# =================

View File

@ -573,10 +573,6 @@ function create_nova_conf {
if [[ -n ${LOGDIR} ]]; then
bash -c "cd '$LOGDIR' && ln -sf '$logfile' ${service}.log"
iniset "$NOVA_CONF_DIR/nova-dhcpbridge.conf" DEFAULT log_file "$real_logfile"
if [[ -n ${SCREEN_LOGDIR} ]]; then
# Drop the backward-compat symlink
ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${service}.log
fi
fi
iniset $NOVA_CONF DEFAULT dhcpbridge_flagfile "$NOVA_CONF_DIR/nova-dhcpbridge.conf"

View File

@ -228,16 +228,6 @@ if [[ ! ${DISTRO} =~ (xenial|yakkety|zesty|stretch|jessie|f24|f25|f26|opensuse-4
fi
fi
# Check to see if we are already running DevStack
# Note that this may fail if USE_SCREEN=False
if type -p screen > /dev/null && screen -ls | egrep -q "[0-9]\.$SCREEN_NAME"; then
echo "You are already running a stack.sh session."
echo "To rejoin this session type 'screen -x stack'."
echo "To destroy this session, type './unstack.sh'."
exit 1
fi
# Local Settings
# --------------
@ -491,24 +481,6 @@ else
exec 6> >( $TOP_DIR/tools/outfilter.py -v >&3 )
fi
# Set up logging of screen windows
# Set ``SCREEN_LOGDIR`` to turn on logging of screen windows to the
# directory specified in ``SCREEN_LOGDIR``, we will log to the file
# ``screen-$SERVICE_NAME-$TIMESTAMP.log`` in that dir and have a link
# ``screen-$SERVICE_NAME.log`` to the latest log file.
# Logs are kept for as long specified in ``LOGDAYS``.
# This is deprecated....logs go in ``LOGDIR``, only symlinks will be here now.
if [[ -n "$SCREEN_LOGDIR" ]]; then
# We make sure the directory is created.
if [[ -d "$SCREEN_LOGDIR" ]]; then
# We cleanup the old logs
find $SCREEN_LOGDIR -maxdepth 1 -name screen-\*.log -mtime +$LOGDAYS -exec rm {} \;
else
mkdir -p $SCREEN_LOGDIR
fi
fi
# Basic test for ``$DEST`` path permissions (fatal on error unless skipped)
check_path_perm_sanity ${DEST}
@ -1015,38 +987,6 @@ if is_service_enabled $DATABASE_BACKENDS; then
configure_database
fi
# Configure screen
# ----------------
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
SCREEN_HARDSTATUS=${SCREEN_HARDSTATUS:-}
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"
screen -r $SCREEN_NAME -X setenv PROMPT_COMMAND /bin/true
if is_service_enabled tls-proxy; then
follow_tls_proxy
fi
fi
# Clear ``screenrc`` file
SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc
if [[ -e $SCREENRC ]]; then
rm -f $SCREENRC
fi
# Initialize the directory for service status check
init_service_check
# Save configuration values
save_stackenv $LINENO

60
stackrc
View File

@ -88,22 +88,9 @@ CELLSV2_SETUP=${CELLSV2_SETUP:-"superconductor"}
# Set the root URL for Horizon
HORIZON_APACHE_ROOT="/dashboard"
# TODO(sdague): Queens
#
# All the non systemd paths should be removed in queens, they only
# exist in Pike to support testing from grenade. Ensure that all this
# is cleaned up and purged, which should dramatically simplify the
# devstack codebase.
# Whether to use 'dev mode' for screen windows. Dev mode works by
# stuffing text into the screen windows so that a developer can use
# ctrl-c, up-arrow, enter to restart the service. Starting services
# this way is slightly unreliable, and a bit slower, so this can
# be disabled for automated testing by setting this value to False.
USE_SCREEN=$(trueorfalse False USE_SCREEN)
# Whether to use SYSTEMD to manage services
USE_SYSTEMD=$(trueorfalse False USE_SYSTEMD)
# Whether to use SYSTEMD to manage services, we only do this from
# Queens forward.
USE_SYSTEMD="True"
USER_UNITS=$(trueorfalse False USER_UNITS)
if [[ "$USER_UNITS" == "True" ]]; then
SYSTEMD_DIR="$HOME/.local/share/systemd/user"
@ -122,16 +109,6 @@ fi
# memory constrained than CPU bound.
ENABLE_KSM=$(trueorfalse True ENABLE_KSM)
# When using screen, should we keep a log file on disk? You might
# want this False if you have a long-running setup where verbose logs
# can fill-up the host.
# XXX: Ideally screen itself would be configured to log but just not
# activate. This isn't possible with the screerc syntax. Temporary
# logging can still be used by a developer with:
# C-a : logfile foo
# C-a : log on
SCREEN_IS_LOGGING=$(trueorfalse True SCREEN_IS_LOGGING)
# Passwords generated by interactive devstack runs
if [[ -r $RC_DIR/.localrc.password ]]; then
source $RC_DIR/.localrc.password
@ -167,16 +144,6 @@ elif [[ -f $RC_DIR/.localrc.auto ]]; then
source $RC_DIR/.localrc.auto
fi
# TODO(sdague): Delete all this in Queens.
if [[ "$USE_SYSTEMD" == "True" ]]; then
USE_SCREEN=False
fi
# if we are forcing off USE_SCREEN (as we do in the gate), force on
# systemd. This allows us to drop one of 3 paths through the code.
if [[ "$USE_SCREEN" == "False" ]]; then
USE_SYSTEMD="True"
fi
# Default for log coloring is based on interactive-or-not.
# Baseline assumption is that non-interactive invocations are for CI,
# where logs are to be presented as browsable text files; hence color
@ -759,9 +726,6 @@ PUBLIC_NETWORK_NAME=${PUBLIC_NETWORK_NAME:-"public"}
PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-""}
# Set default screen name
SCREEN_NAME=${SCREEN_NAME:-stack}
# Allow the use of an alternate protocol (such as https) for service endpoints
SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http}
@ -881,15 +845,6 @@ RECREATE_KEYSTONE_DB=$(trueorfalse True RECREATE_KEYSTONE_DB)
# Following entries need to be last items in file
# Compatibility bits required by other callers like Grenade
# Old way was using SCREEN_LOGDIR to locate those logs and LOGFILE for the stack.sh trace log.
# LOGFILE SCREEN_LOGDIR output
# not set not set no log files
# set not set stack.sh log to LOGFILE
# not set set screen logs to SCREEN_LOGDIR
# set set stack.sh log to LOGFILE, screen logs to SCREEN_LOGDIR
# New way is LOGDIR for all logs and LOGFILE for stack.sh trace log, but if not fully-qualified will be in LOGDIR
# LOGFILE LOGDIR output
# not set not set (new) set LOGDIR from default
@ -897,9 +852,6 @@ RECREATE_KEYSTONE_DB=$(trueorfalse True RECREATE_KEYSTONE_DB)
# not set set screen logs to LOGDIR
# set set stack.sh log to LOGFILE, screen logs to LOGDIR
# For compat, if SCREEN_LOGDIR is set, it will be used to create back-compat symlinks to the LOGDIR
# symlinks to SCREEN_LOGDIR (compat)
# Set up new logging defaults
if [[ -z "${LOGDIR:-}" ]]; then
default_logdir=$DEST/logs
@ -914,12 +866,6 @@ if [[ -z "${LOGDIR:-}" ]]; then
# LOGFILE had no path, set a default
LOGDIR="$default_logdir"
fi
# Check for duplication
if [[ "${SCREEN_LOGDIR:-}" == "${LOGDIR}" ]]; then
# We don't need the symlinks since it's the same directory
unset SCREEN_LOGDIR
fi
fi
unset default_logdir logfile
fi

View File

@ -1,109 +0,0 @@
#!/bin/bash
# tests/exec.sh - Test DevStack run_process() and stop_process()
#
# exec.sh start|stop|status
#
# Set USE_SCREEN True|False to change use of screen.
#
# This script emulates the basic exec environment in ``stack.sh`` to test
# the process spawn and kill operations.
if [[ -z $1 ]]; then
echo "$0 start|stop"
exit 1
fi
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
source $TOP_DIR/functions
USE_SCREEN=${USE_SCREEN:-False}
ENABLED_SERVICES=fake-service
SERVICE_DIR=/tmp
SCREEN_NAME=test
SCREEN_LOGDIR=${SERVICE_DIR}/${SCREEN_NAME}
# Kill background processes on exit
trap clean EXIT
clean() {
local r=$?
jobs -p
kill >/dev/null 2>&1 $(jobs -p)
exit $r
}
# Exit on any errors so that errors don't compound
trap failed ERR
failed() {
local r=$?
jobs -p
kill >/dev/null 2>&1 $(jobs -p)
set +o xtrace
[ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE"
exit $r
}
function status {
if [[ -r $SERVICE_DIR/$SCREEN_NAME/fake-service.pid ]]; then
pstree -pg $(cat $SERVICE_DIR/$SCREEN_NAME/fake-service.pid)
fi
ps -ef | grep fake
}
function setup_screen {
if [[ ! -d $SERVICE_DIR/$SCREEN_NAME ]]; then
rm -rf $SERVICE_DIR/$SCREEN_NAME
mkdir -p $SERVICE_DIR/$SCREEN_NAME
fi
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
SCREENRC=$TOP_DIR/tests/$SCREEN_NAME-screenrc
if [[ -e $SCREENRC ]]; then
echo -n > $SCREENRC
fi
}
# Mimic logging
# Set up output redirection without log files
# Copy stdout to fd 3
exec 3>&1
if [[ "$VERBOSE" != "True" ]]; then
# Throw away stdout and stderr
#exec 1>/dev/null 2>&1
:
fi
# Always send summary fd to original stdout
exec 6>&3
if [[ "$1" == "start" ]]; then
echo "Start service"
setup_screen
run_process fake-service "$TOP_DIR/tests/fake-service.sh"
sleep 1
status
elif [[ "$1" == "stop" ]]; then
echo "Stop service"
stop_process fake-service
status
elif [[ "$1" == "status" ]]; then
status
else
echo "Unknown command"
exit 1
fi

View File

@ -171,15 +171,6 @@ if is_service_enabled dstat; then
stop_dstat
fi
# Clean up the remainder of the screen processes
SCREEN=$(which screen)
if [[ -n "$SCREEN" ]]; then
SESSION=$(screen -ls | awk "/[0-9]+.${SCREEN_NAME}/"'{ print $1 }')
if [[ -n "$SESSION" ]]; then
screen -X -S $SESSION quit
fi
fi
# NOTE: Cinder automatically installs the lvm2 package, independently of the
# enabled backends. So if Cinder is enabled, and installed successfully we are
# sure lvm2 (lvremove, /etc/lvm/lvm.conf, etc.) is here.