diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9a36f599e5..d6c19a379e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -282,12 +282,13 @@ jobs: - name: Compress Service Logs Before upload if: ${{ failure() }} run: | + ./tools/launchdev.sh stop # stop st2 before collecting logs tar cvzpf logs.tar.gz logs/* - name: Upload StackStorm services Logs if: ${{ failure() }} uses: actions/upload-artifact@v2 with: - name: logs + name: logs-py${{ matrix.python-version }} path: logs.tar.gz retention-days: 7 - name: Stop Redis Service Container @@ -690,12 +691,13 @@ jobs: - name: Compress Service Logs Before upload if: ${{ failure() && env.TASK == 'ci-integration' }} run: | + ./tools/launchdev.sh stop # stop st2 before collecting logs tar cvzpf logs.tar.gz logs/* - name: Upload StackStorm services Logs if: ${{ failure() && env.TASK == 'ci-integration' }} uses: actions/upload-artifact@v2 with: - name: logs + name: logs-py${{ matrix.python-version }}-nose-${{ matrix.nosetests_node_index }} path: logs.tar.gz retention-days: 7 - name: Stop Redis Service Container diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9c9a2cef73..c86714fc11 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,7 @@ Changed * Switch to python3's standard lib unittest from unittest2, a backport of python3 unittest features for python2. #6187 (by @nzlosh) * Drop Python 3.6 testing in CircleCI. #6080 Contributed by (@philipphomberger Schwarz IT KG) +* Refactor `tools/launchdev.sh` to use `tmux` instead of `screen`. #6186 (by @nzlosh and @cognifloyd) Added ~~~~~ diff --git a/dev_docs/Troubleshooting_Guide.rst b/dev_docs/Troubleshooting_Guide.rst index f61cedcba4..1b89ca8a71 100644 --- a/dev_docs/Troubleshooting_Guide.rst +++ b/dev_docs/Troubleshooting_Guide.rst @@ -40,17 +40,15 @@ As we can see from above output port ``9101`` is not even up. To verify this let vagrant 32403 0.2 1.5 79228 31364 pts/3 Ss+ 18:27 0:00 /home/vagrant/git/st2/virtualenv/bin/python ./virtualenv/bin/gunicorn st2stream.wsgi:application -k eventlet -b 0.0.0.0:9102 --workers 1 -- This suggests that the API process crashed, we can verify that by running ``screen -ls``.:: +- This suggests that the API process crashed, we can verify that by running ``tmux ls``.:: .. code:: bash - $ screen -ls - There are screens on: - 15781.st2-auth (04/26/2016 06:39:10 PM) (Detached) - 15778.st2-notifier (04/26/2016 06:39:10 PM) (Detached) - 15767.st2-sensorcontainer (04/26/2016 06:39:10 PM) (Detached) - 15762.st2-stream (04/26/2016 06:39:10 PM) (Detached) - 3 Sockets in /var/run/screen/S-vagrant. + $ tmux ls + st2-auth: 1 windows (created Fri Apr 19 00:42:58 2024) + st2-notifier: 1 windows (created Fri Apr 19 00:42:58 2024) + st2-sensorcontainer: 1 windows (created Fri Apr 19 00:42:58 2024) + st2-stream: 1 windows (created Fri Apr 19 00:42:58 2024) - Now let us check the logs for any errors: diff --git a/scripts/github/prepare-integration.sh b/scripts/github/prepare-integration.sh index 9e13ade526..a9011bc080 100755 --- a/scripts/github/prepare-integration.sh +++ b/scripts/github/prepare-integration.sh @@ -30,23 +30,23 @@ echo "" python ./st2client/setup.py develop st2 --version -# Clean up old screen log files -rm -f logs/screen-*.log +# Clean up old st2 log files +rm -f logs/st2*.log # ::group::/::endgroup:: is helpful github actions syntax to fold this section. echo ::group::launchdev.sh start -x -# start dev environment in screens +# start dev environment in tmux ./tools/launchdev.sh start -x # Give processes some time to start and check logs to see if all the services # started or if there was any error / failure -echo "Giving screen processes some time to start..." +echo "Giving st2 processes some time to start..." sleep 10 -echo " === START: Catting screen process log files. ===" -cat logs/screen-*.log -echo " === END: Catting screen process log files. ===" +echo " === START: Catting st2 process log files. ===" +cat logs/st2-*.log +echo " === END: Catting st2 process log files. ===" # github actions: fold for launchdev.sh start -x echo ::endgroup:: diff --git a/tools/launchdev.sh b/tools/launchdev.sh index d0c777f996..82d0083f09 100755 --- a/tools/launchdev.sh +++ b/tools/launchdev.sh @@ -1,7 +1,18 @@ #!/usr/bin/env bash +set +x + function usage() { - echo "Usage: $0 [start|stop|restart|startclean] [-r runner_count] [-s scheduler_count] [-w workflow_engine_count] [-g] [-x] [-c] [-6] [-m]" >&2 + cat<&2 + Usage: $0 [start|stop|restart|startclean] [-r runner_count] [-s scheduler_count] [-w workflow_engine_count] [-g] [-x] [-c] [-6] + -r : the number of st2runner instances start + -s : the numer of st2scheduler instances to start + -w : the numer of st2workflow-engine instances to start + -g : disable gunicorn + -x : enable copy test packs + -c : disable load content + -6 : enable use of ipv6 +EOF } subcommand=$1; shift @@ -49,13 +60,49 @@ while getopts ":r:s:w:gxcu6" o; do esac done -function init(){ +# Colour echo +function cecho() +{ + if [[ "$1" == "-n" ]]; then + # No carrage return + NCR="$1"; shift + else + NCR="" + fi + C="$1"; shift + MSG="$1" + echo $NCR -e "\e[${C}m${MSG}\e[0m" +} + +function heading() +{ + MSG="$1" + cecho "34;7" "$MSG" +} +function iecho() +{ + MSG="$1" + cecho "37;1" "$MSG" +} +function wecho() +{ + MSG="$1" + cecho "33;1" "$MSG" +} +function eecho() +{ + MSG="$1" + cecho "31;1" "$MSG" +} +function init() +{ + heading "Initialising system variables ..." ST2_BASE_DIR="/opt/stackstorm" COMMAND_PATH=${0%/*} - CURRENT_DIR=`pwd` - CURRENT_USER=`whoami` - CURRENT_USER_GROUP=`id -gn` - echo "Current user:group = ${CURRENT_USER}:${CURRENT_USER_GROUP}" + CURRENT_DIR=$(pwd) + CURRENT_USER=$(whoami) + CURRENT_USER_GROUP=$(id -gn) + echo -n "Current user:group = "; iecho "${CURRENT_USER}:${CURRENT_USER_GROUP}" if [[ (${COMMAND_PATH} == /*) ]] ; then @@ -63,75 +110,76 @@ function init(){ else ST2_REPO=${CURRENT_DIR}/${COMMAND_PATH}/.. fi - + ST2_LOGS="${ST2_REPO}/logs" VIRTUALENV=${VIRTUALENV_DIR:-${ST2_REPO}/virtualenv} VIRTUALENV=$(readlink -f ${VIRTUALENV}) PY=${VIRTUALENV}/bin/python PYTHON_VERSION=$(${PY} --version 2>&1) - echo "Using virtualenv: ${VIRTUALENV}" - echo "Using python: ${PY} (${PYTHON_VERSION})" + echo -n "Using virtualenv: "; iecho "${VIRTUALENV}" + echo -n "Using python: "; iecho "${PY} (${PYTHON_VERSION})" + echo -n "Log file location: "; iecho "${ST2_LOGS}" if [ -z "$ST2_CONF" ]; then ST2_CONF=${ST2_REPO}/conf/st2.dev.conf fi ST2_CONF=$(readlink -f ${ST2_CONF}) - echo "Using st2 config file: $ST2_CONF" + echo -n "Using st2 config file: "; iecho "$ST2_CONF" if [ ! -f "$ST2_CONF" ]; then - echo "Config file $ST2_CONF does not exist." + eecho "Config file $ST2_CONF does not exist." exit 1 fi } -function exportsdir(){ +function exportsdir() +{ local EXPORTS_DIR=$(grep 'dump_dir' ${ST2_CONF} | sed -e "s~^dump_dir[ ]*=[ ]*\(.*\)~\1~g") if [ -z $EXPORTS_DIR ]; then EXPORTS_DIR="/opt/stackstorm/exports" fi - echo "$EXPORTS_DIR" + echo -n "Export directories: "; iecho "$EXPORTS_DIR" } -function st2start(){ - echo "Starting all st2 servers..." +function st2start() +{ + heading "Starting all st2 servers ..." # Determine where the st2 repo is located. Some assumption is made here # that this script is located under st2/tools. # Change working directory to the root of the repo. - echo "Changing working directory to ${ST2_REPO}" + echo -n "Changing working directory to "; iecho "${ST2_REPO}" cd ${ST2_REPO} - BASE_DIR=$(grep 'base_path' ${ST2_CONF} \ - | awk 'BEGIN {FS=" = "}; {print $2}') + BASE_DIR=$(grep 'base_path' ${ST2_CONF} | awk 'BEGIN {FS=" = "}; {print $2}') if [ -z BASE_DIR ]; then BASE_DIR="/opt/stackstorm" fi CONFIG_BASE_DIR="${BASE_DIR}/configs" - echo "Using config base dir: $CONFIG_BASE_DIR" + echo -n "Using config base dir: "; iecho "$CONFIG_BASE_DIR" if [ ! -d "$CONFIG_BASE_DIR" ]; then - echo "$CONFIG_BASE_DIR doesn't exist. Creating..." + wecho "$CONFIG_BASE_DIR doesn't exist. Creating ..." sudo mkdir -p $CONFIG_BASE_DIR fi - PACKS_BASE_DIR=$(grep 'packs_base_path' ${ST2_CONF} \ - | awk 'BEGIN {FS=" = "}; {print $2}') + PACKS_BASE_DIR=$(grep 'packs_base_path' ${ST2_CONF} | awk 'BEGIN {FS=" = "}; {print $2}') if [ -z $PACKS_BASE_DIR ]; then PACKS_BASE_DIR="/opt/stackstorm/packs" fi - echo "Using content packs base dir: $PACKS_BASE_DIR" + echo -n "Using content packs base dir: "; iecho "$PACKS_BASE_DIR" # Copy and overwrite the action contents if [ ! -d "$ST2_BASE_DIR" ]; then - echo "$ST2_BASE_DIR doesn't exist. Creating..." + wecho "$ST2_BASE_DIR doesn't exist. Creating ..." sudo mkdir -p $PACKS_BASE_DIR fi if [ "${use_ipv6}" = true ]; then - echo ' using IPv6 bindings...' + echo ' using IPv6 bindings ...' BINDING_ADDRESS="[::]" else BINDING_ADDRESS="0.0.0.0" @@ -150,7 +198,7 @@ function st2start(){ cp -Rp ./contrib/packs/ $PACKS_BASE_DIR if [ "$copy_test_packs" = true ]; then - echo "Copying test packs examples and fixtures to $PACKS_BASE_DIR" + echo -n "Copying test packs examples and fixtures to "; iecho "$PACKS_BASE_DIR" cp -Rp ./contrib/examples $PACKS_BASE_DIR # Clone st2tests in /tmp directory. pushd /tmp @@ -162,138 +210,113 @@ function st2start(){ cp -Rp ./st2tests/packs/fixtures $PACKS_BASE_DIR rm -R st2tests/ else - echo "Failed to clone st2tests repo" + eecho "Failed to clone st2tests repo" fi popd fi # activate virtualenv to set PYTHONPATH source ${VIRTUALENV}/bin/activate + # set configuration file location. + export ST2_CONFIG_PATH=${ST2_CONF}; - # Kill existing st2 screens - screen -wipe - screen -ls | grep st2 &> /dev/null - if [ $? == 0 ]; then - echo 'Killing existing st2 screen sessions...' - screen -ls | grep st2 | cut -d. -f1 | awk '{print $1}' | xargs kill - fi - - # NOTE: We can't rely on latest version of screen with "-Logfile path" - # option so we need to use screen config file per screen window + # Kill existing st2 terminal multiplexor sessions + for tmux_session in $(tmux ls | awk -F: '/^st2-/ {print $1}') + do + echo "Kill existing session $tmux_session" + tmux kill-session -t $tmux_session + done # Run the st2 API server - echo 'Starting screen session st2-api...' if [ "${use_gunicorn}" = true ]; then - echo ' using gunicorn to run st2-api...' - export ST2_CONFIG_PATH=${ST2_CONF} - screen -L -c tools/screen-configs/st2api.conf -d -m -S st2-api ${VIRTUALENV}/bin/gunicorn \ - st2api.wsgi:application -k eventlet -b "$BINDING_ADDRESS:9101" --workers 1 + echo 'Starting st2-api using gunicorn ...' + tmux new-session -d -s st2-api "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/gunicorn st2api.wsgi:application -k eventlet -b $BINDING_ADDRESS:9101 --workers 1 2>&1 | tee -a ${ST2_LOGS}/st2-api.log" else - screen -L -c tools/screen-configs/st2api.conf -d -m -S st2-api ${VIRTUALENV}/bin/python \ - ./st2api/bin/st2api \ - --config-file $ST2_CONF + echo 'Starting st2-api ...' + tmux new-session -d -s st2-api "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2api/bin/st2api --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-api.log" fi # Run st2stream API server if [ "${use_gunicorn}" = true ]; then - echo ' using gunicorn to run st2-stream' - export ST2_CONFIG_PATH=${ST2_CONF} - screen -L -c tools/screen-configs/st2stream.conf -d -m -S st2-stream ${VIRTUALENV}/bin/gunicorn \ - st2stream.wsgi:application -k eventlet -b "$BINDING_ADDRESS:9102" --workers 1 + echo 'Starting st2-stream using gunicorn ...' + tmux new-session -d -s st2-stream "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/gunicorn st2stream.wsgi:application -k eventlet -b $BINDING_ADDRESS:9102 --workers 1 2>&1 | tee -a ${ST2_LOGS}/st2-stream.log" else - screen -L -c tools/screen-configs/st2stream.conf -d -m -S st2-stream ${VIRTUALENV}/bin/python \ - ./st2stream/bin/st2stream \ - --config-file $ST2_CONF + echo 'Starting st2-stream ...' + tmux new-session -d -s st2-stream "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2stream/bin/st2stream --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-stream.log" fi + # give st2stream time to startup and load things into database + sleep 10 + # Run the workflow engine server - echo 'Starting screen session st2-workflow(s)' - WORKFLOW_ENGINE_SCREENS=() + echo 'Starting st2-workflow engine(s):' + WORKFLOW_ENGINE_SESSIONS=() for i in $(seq 1 $workflow_engine_count) do WORKFLOW_ENGINE_NAME=st2-workflow-$i - WORKFLOW_ENGINE_SCREENS+=($WORKFLOW_ENGINE_NAME) - echo ' starting '$WORKFLOW_ENGINE_NAME'...' - screen -L -c tools/screen-configs/st2workflowengine.conf -d -m -S $WORKFLOW_ENGINE_NAME ${VIRTUALENV}/bin/python \ - ./st2actions/bin/st2workflowengine \ - --config-file $ST2_CONF + WORKFLOW_ENGINE_SESSIONS+=($WORKFLOW_ENGINE_NAME) + echo " $WORKFLOW_ENGINE_NAME ..." + tmux new-session -d -s $WORKFLOW_ENGINE_NAME "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2actions/bin/st2workflowengine --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/${WORKFLOW_ENGINE_NAME}.log" done - # Start a screen for every runner - echo 'Starting screen sessions for st2-actionrunner(s)' - RUNNER_SCREENS=() + # Start a session for every runner + echo 'Starting st2-actionrunner(s):' + RUNNER_SESSIONS=() for i in $(seq 1 $runner_count) do RUNNER_NAME=st2-actionrunner-$i - RUNNER_SCREENS+=($RUNNER_NAME) - echo ' starting '$RUNNER_NAME'...' - screen -L -c tools/screen-configs/st2actionrunner.conf -d -m -S $RUNNER_NAME ${VIRTUALENV}/bin/python \ - ./st2actions/bin/st2actionrunner \ - --config-file $ST2_CONF + RUNNER_SESSIONS+=($RUNNER_NAME) + echo " $RUNNER_NAME ..." + tmux new-session -d -s $RUNNER_NAME "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2actions/bin/st2actionrunner --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/${RUNNER_NAME}.log" done # Run the garbage collector service - echo 'Starting screen session st2-garbagecollector' - screen -L -c tools/screen-configs/st2garbagecollector.conf -d -m -S st2-garbagecollector ${VIRTUALENV}/bin/python \ - ./st2reactor/bin/st2garbagecollector \ - --config-file $ST2_CONF + echo 'Starting st2-garbagecollector ...' + tmux new-session -d -s st2-garbagecollector "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2reactor/bin/st2garbagecollector --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-garbagecollector.log" # Run the scheduler server - echo 'Starting screen session st2-scheduler(s)' - SCHEDULER_SCREENS=() + echo 'Starting st2-scheduler(s):' + SCHEDULER_SESSIONS=() for i in $(seq 1 $scheduler_count) do SCHEDULER_NAME=st2-scheduler-$i - SCHEDULER_SCREENS+=($SCHEDULER_NAME) - echo ' starting '$SCHEDULER_NAME'...' - screen -L -c tools/screen-configs/st2scheduler.conf -d -m -S $SCHEDULER_NAME ${VIRTUALENV}/bin/python \ - ./st2actions/bin/st2scheduler \ - --config-file $ST2_CONF + SCHEDULER_SESSIONS+=($SCHEDULER_NAME) + echo " $SCHEDULER_NAME ..." + tmux new-session -d -s $SCHEDULER_NAME "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2actions/bin/st2scheduler --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/${SCHEDULER_NAME}.log" done # Run the sensor container server - echo 'Starting screen session st2-sensorcontainer' - screen -L -c tools/screen-configs/st2sensorcontainer.conf -d -m -S st2-sensorcontainer ${VIRTUALENV}/bin/python \ - ./st2reactor/bin/st2sensorcontainer \ - --config-file $ST2_CONF + echo 'Starting st2-sensorcontainer ...' + tmux new-session -d -s st2-sensorcontainer "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2reactor/bin/st2sensorcontainer --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-sensorcontainer.log" # Run the rules engine server - echo 'Starting screen session st2-rulesengine...' - screen -L -c tools/screen-configs/st2rulesengine.conf -d -m -S st2-rulesengine ${VIRTUALENV}/bin/python \ - ./st2reactor/bin/st2rulesengine \ - --config-file $ST2_CONF + echo 'Starting st2-rulesengine ...' + tmux new-session -d -s st2-rulesengine "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2reactor/bin/st2rulesengine --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-rulesengine.log" # Run the timer engine server - echo 'Starting screen session st2-timersengine...' - screen -L -c tools/screen-configs/st2timersengine.conf -d -m -S st2-timersengine ${VIRTUALENV}/bin/python \ - ./st2reactor/bin/st2timersengine \ - --config-file $ST2_CONF + echo 'Starting st2-timersengine ...' + tmux new-session -d -s st2-timersengine "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2reactor/bin/st2timersengine --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-timersengine.log" # Run the actions notifier - echo 'Starting screen session st2-notifier...' - screen -L -c tools/screen-configs/st2notifier.conf -d -m -S st2-notifier ${VIRTUALENV}/bin/python \ - ./st2actions/bin/st2notifier \ - --config-file $ST2_CONF + echo 'Starting st2-notifier ...' + tmux new-session -d -s st2-notifier "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2actions/bin/st2notifier --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-notifier.log" # Run the auth API server - echo 'Starting screen session st2-auth...' if [ "${use_gunicorn}" = true ]; then - echo ' using gunicorn to run st2-auth...' + echo 'Starting st2-auth using gunicorn ...' export ST2_CONFIG_PATH=${ST2_CONF} - screen -L -c tools/screen-configs/st2auth.conf -d -m -S st2-auth ${VIRTUALENV}/bin/gunicorn \ - st2auth.wsgi:application -k eventlet -b "$BINDING_ADDRESS:9100" --workers 1 + tmux new-session -d -s st2-auth "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/gunicorn st2auth.wsgi:application -k eventlet -b $BINDING_ADDRESS:9100 --workers 1 2>&1 | tee -a ${ST2_LOGS}/st2-auth.log" else - screen -L -c tools/screen-configs/st2auth.conf -d -m -S st2-auth ${VIRTUALENV}/bin/python \ - ./st2auth/bin/st2auth \ - --config-file $ST2_CONF + echo 'Starting st2-auth ...' + tmux new-session -d -s st2-auth "export ST2_CONFIG_PATH=${ST2_CONF}; source ${VIRTUALENV}/bin/activate; ${VIRTUALENV}/bin/python ./st2auth/bin/st2auth --config-file $ST2_CONF 2>&1 | tee -a ${ST2_LOGS}/st2-auth.log" fi - # Check whether screen sessions are started - SCREENS=( + # Check whether tmux sessions are started + SESSIONS=( "st2-api" - "${WORKFLOW_ENGINE_SCREENS[@]}" - "${SCHEDULER_SCREENS[@]}" - "${RUNNER_SCREENS[@]}" + "${WORKFLOW_ENGINE_SESSIONS[@]}" + "${SCHEDULER_SESSIONS[@]}" + "${RUNNER_SESSIONS[@]}" "st2-sensorcontainer" "st2-rulesengine" "st2-notifier" @@ -303,45 +326,44 @@ function st2start(){ ) echo - for s in "${SCREENS[@]}" + for s in "${SESSIONS[@]}" do - screen -ls | grep "${s}[[:space:]]" &> /dev/null + tmux ls | grep "^${s}[[:space:]]" &> /dev/null if [ $? != 0 ]; then - echo "ERROR: Unable to start screen session for $s." + eecho "ERROR: terminal multiplex session for $s failed to start." fi done if [ "$load_content" = true ]; then # Register contents - echo 'Registering sensors, runners, actions, rules, aliases, and policies...' - ${VIRTUALENV}/bin/python \ - ./st2common/bin/st2-register-content \ - --config-file $ST2_CONF --register-all + echo 'Registering sensors, runners, actions, rules, aliases, and policies ...' + ${VIRTUALENV}/bin/python ./st2common/bin/st2-register-content --config-file $ST2_CONF --register-all fi if [ "$copy_test_packs" = true ]; then st2 run packs.setup_virtualenv packs=fixtures if [ $? != 0 ]; then - echo "Warning: Unable to setup virtualenv for the \"tests\" pack. Please setup virtualenv for the \"tests\" pack before running integration tests" + wecho "WARNING: Unable to setup virtualenv for the \"tests\" pack. Please setup virtualenv for the \"tests\" pack before running integration tests" fi fi - # Print default creds to the screen - echo "The default creds are testu:testp" + # Display default credentials to the multiplexor session + echo "The default credentials are testu:testp" - # List screen sessions - screen -ls || exit 0 + # List sessions + tmux ls || exit 0 } -function st2stop(){ - screen -ls | grep st2 &> /dev/null - if [ $? == 0 ]; then - echo 'Killing existing st2 screen sessions...' - screen -ls | grep st2 | cut -d. -f1 | awk '{print $1}' | xargs -L 1 pkill -P - fi +function st2stop() +{ + for tmux_session in $(tmux ls | awk -F: '/^st2-/ {print $1}') + do + echo "Kill existing session $tmux_session" + tmux kill-session -t $tmux_session + done if [ "${use_gunicorn}" = true ]; then - pids=`ps -ef | grep "wsgi:application" | grep -v "grep" | awk '{print $2}'` + pids=$(ps -ef | grep "wsgi:application" | grep -v "grep" | awk '{print $2}') if [ -n "$pids" ]; then echo "Killing gunicorn processes" # true ensures that any failure to kill a process which does not exist will not lead @@ -354,7 +376,8 @@ function st2stop(){ fi } -function st2clean(){ +function st2clean() +{ # clean mongo . ${VIRTUALENV}/bin/activate python ${ST2_REPO}/st2common/bin/st2-cleanup-db --config-file $ST2_CONF @@ -367,33 +390,32 @@ function st2clean(){ fi if [ -n "$ST2_EXPORTER" ]; then EXPORTS_DIR=$(exportsdir) - echo "Removing $EXPORTS_DIR..." + echo "Removing $EXPORTS_DIR ..." rm -rf ${EXPORTS_DIR} fi - } case ${subcommand} in -start) - init - st2start - ;; -startclean) - init - st2clean - st2start - ;; -stop) - st2stop - ;; -restart) - st2stop - sleep 1 - init - st2start - ;; -*) - usage - ;; + start) + init + st2start + ;; + startclean) + init + st2clean + st2start + ;; + stop) + st2stop + ;; + restart) + st2stop + sleep 1 + init + st2start + ;; + *) + usage + ;; esac diff --git a/tools/screen-configs/st2actionrunner.conf b/tools/screen-configs/st2actionrunner.conf deleted file mode 100644 index c7c8d900a1..0000000000 --- a/tools/screen-configs/st2actionrunner.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2actionrunner.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2api.conf b/tools/screen-configs/st2api.conf deleted file mode 100644 index 834313114b..0000000000 --- a/tools/screen-configs/st2api.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2api.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2auth.conf b/tools/screen-configs/st2auth.conf deleted file mode 100644 index 0bff41afcb..0000000000 --- a/tools/screen-configs/st2auth.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2auth.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2garbagecollector.conf b/tools/screen-configs/st2garbagecollector.conf deleted file mode 100644 index dddb0f68f4..0000000000 --- a/tools/screen-configs/st2garbagecollector.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2garbagecollector.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2notifier.conf b/tools/screen-configs/st2notifier.conf deleted file mode 100644 index 104d873a39..0000000000 --- a/tools/screen-configs/st2notifier.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2notifier.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2rulesengine.conf b/tools/screen-configs/st2rulesengine.conf deleted file mode 100644 index 1fca4d9807..0000000000 --- a/tools/screen-configs/st2rulesengine.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2rulesengine.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2scheduler.conf b/tools/screen-configs/st2scheduler.conf deleted file mode 100644 index 1bbcbd81f6..0000000000 --- a/tools/screen-configs/st2scheduler.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2scheduler.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2sensorcontainer.conf b/tools/screen-configs/st2sensorcontainer.conf deleted file mode 100644 index 735550d07b..0000000000 --- a/tools/screen-configs/st2sensorcontainer.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2sensorcontainer.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2stream.conf b/tools/screen-configs/st2stream.conf deleted file mode 100644 index e6c6b8c09e..0000000000 --- a/tools/screen-configs/st2stream.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2stream.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2timersengine.conf b/tools/screen-configs/st2timersengine.conf deleted file mode 100644 index 5d358d8fec..0000000000 --- a/tools/screen-configs/st2timersengine.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2timersengine.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on diff --git a/tools/screen-configs/st2workflowengine.conf b/tools/screen-configs/st2workflowengine.conf deleted file mode 100644 index 28d110e29c..0000000000 --- a/tools/screen-configs/st2workflowengine.conf +++ /dev/null @@ -1,6 +0,0 @@ -logfile logs/screen-st2workflowengine.log -logfile flush 1 -log on -logtstamp after 1 -logtstamp string \"[ %t: %Y-%m-%d %c:%s ]\012\" -logtstamp on