StackStorm / st2chatops

Packaging environment for building StackStorm chatops native packages
Apache License 2.0
32 stars 42 forks source link

Installer waits forever on el6 if HUBOT_SLACK_TOKEN is defined #96

Open warrenvw opened 7 years ago

warrenvw commented 7 years ago

NOTE: This issue only applies to el6 systems.

Define the HUBOT_SLACK_TOKEN variable, and then install BWC using:

curl -sSL -O https://brocade.com/bwc/install/install.sh && chmod +x install.sh
./install.sh --user=st2admin --password='Ch@ngeMe' --license=${BWC_LICENSE_KEY}

After displaying the ok_message, the installer will wait forever. CTRL-C to proceed, and CTRL-C again to cancel the BWC installation.

After cancelling the installation, you can reproduce the issue by executing the following script any number of times:

#!/bin/bash

adddate() {
    while IFS= read -r line; do
        echo "$(date +%Y%m%dT%H%M%S%z) $line"
    done
}

configure_st2chatops() {
  echo "Start"
  sudo service st2chatops restart
  echo "Finish"
}

configure_st2chatops | adddate | sudo tee a
exit ${PIPESTATUS[0]}

You'll notice that configure_st2chatops finishes, but the pipe never closes. You can remove adddate from the pipe, but that makes no difference. If you replace configure_st2chatops | adddate | sudo tee a with configure_st2chatops, then the script finishes as expected (but then there's no logging with timestamps).

On the other hand, if you leave the pipe as specified above, but comment out sudo service st2chatops restart, the pipe closes successfully.

We can conclude there's something in sudo service st2chatops restart that doesn't interact well with pipes. The other services on el6 use the daemon function as opposed to nohup_start. Compare https://github.com/StackStorm/st2chatops/blob/master/rpm/st2chatops.init with https://github.com/StackStorm/st2-packages/blob/master/packages/st2/rpm/st2api.init

I was unable to replace nohup_start with daemon in a way that successfully started st2chatops (i.e., hubot). Hopefully I've provided enough information here so someone else can easily fix. If not, I'll try to figure it out.

warrenvw commented 7 years ago

I should add that while appending > /dev/null to sudo service st2chatops restart makes the above script work, it will not work in the actual st2bootstrap-el6.sh script.