This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/fluo-uno.git
The following commit(s) were added to refs/heads/master by this push: new 1d61a7f fixes #185 No longer write to stdin (#187) 1d61a7f is described below commit 1d61a7fcd6fcabe37272dca606c2de26d5662b57 Author: Keith Turner <ke...@deenlo.com> AuthorDate: Mon Jul 23 17:31:05 2018 -0400 fixes #185 No longer write to stdin (#187) --- bin/impl/setup-accumulo.sh | 2 +- bin/impl/setup-fluo-yarn.sh | 6 +++--- bin/impl/setup-fluo.sh | 6 +++--- bin/impl/setup-hadoop.sh | 2 +- bin/impl/setup-metrics.sh | 28 ++++++++++++++-------------- bin/impl/setup-spark.sh | 4 ++-- bin/impl/setup-zookeeper.sh | 2 +- bin/impl/util.sh | 25 +++++++++++++++++++++---- bin/uno | 1 + 9 files changed, 47 insertions(+), 29 deletions(-) diff --git a/bin/impl/setup-accumulo.sh b/bin/impl/setup-accumulo.sh index ec179ad..306dddc 100755 --- a/bin/impl/setup-accumulo.sh +++ b/bin/impl/setup-accumulo.sh @@ -30,7 +30,7 @@ pkill -f accumulo.start # stop if any command fails set -e -echo >&0 "Setting up Apache Accumulo at $ACCUMULO_HOME" +print_to_console "Setting up Apache Accumulo at $ACCUMULO_HOME" rm -rf "$INSTALL"/accumulo-* rm -f "$ACCUMULO_LOG_DIR"/* diff --git a/bin/impl/setup-fluo-yarn.sh b/bin/impl/setup-fluo-yarn.sh index ddcbafb..8bf0d31 100755 --- a/bin/impl/setup-fluo-yarn.sh +++ b/bin/impl/setup-fluo-yarn.sh @@ -28,7 +28,7 @@ if [[ $1 != "--no-deps" ]]; then fi if [[ -f "$DOWNLOADS/$FLUO_YARN_TARBALL" ]]; then - echo >&0 "Setting up Apache Fluo YARN launcher at $FLUO_YARN_HOME" + print_to_console "Setting up Apache Fluo YARN launcher at $FLUO_YARN_HOME" # Don't stop if pkills fail set +e pkill -f "fluo\.yarn" @@ -53,6 +53,6 @@ if [[ -f "$DOWNLOADS/$FLUO_YARN_TARBALL" ]]; then stty sane else - echo >&0 "WARNING: Apache Fluo YARN launcher tarball '$FLUO_YARN_TARBALL' was not found in $DOWNLOADS." - echo >&0 "Apache Fluo YARN launcher will not be set up!" + print_to_console "WARNING: Apache Fluo YARN launcher tarball '$FLUO_YARN_TARBALL' was not found in $DOWNLOADS." + print_to_console "Apache Fluo YARN launcher will not be set up!" fi diff --git a/bin/impl/setup-fluo.sh b/bin/impl/setup-fluo.sh index 424a74d..bd487e8 100755 --- a/bin/impl/setup-fluo.sh +++ b/bin/impl/setup-fluo.sh @@ -28,7 +28,7 @@ if [[ $1 != "--no-deps" ]]; then fi if [[ -f "$DOWNLOADS/$FLUO_TARBALL" ]]; then - echo >&0 "Setting up Apache Fluo at $FLUO_HOME" + print_to_console "Setting up Apache Fluo at $FLUO_HOME" # Don't stop if pkills fail set +e pkill -f fluo.yarn @@ -72,6 +72,6 @@ if [[ -f "$DOWNLOADS/$FLUO_TARBALL" ]]; then stty sane else - echo >&0 "WARNING: Apache Fluo tarball '$FLUO_TARBALL' was not found in $DOWNLOADS." - echo >&0 "Apache Fluo will not be set up!" + print_to_console "WARNING: Apache Fluo tarball '$FLUO_TARBALL' was not found in $DOWNLOADS." + print_to_console "Apache Fluo will not be set up!" fi diff --git a/bin/impl/setup-hadoop.sh b/bin/impl/setup-hadoop.sh index d8a81ff..483223e 100755 --- a/bin/impl/setup-hadoop.sh +++ b/bin/impl/setup-hadoop.sh @@ -24,7 +24,7 @@ pkill -f hadoop.yarn # stop if any command fails set -e -echo >&0 "Setting up Apache Hadoop at $HADOOP_PREFIX" +print_to_console "Setting up Apache Hadoop at $HADOOP_PREFIX" rm -rf "$INSTALL"/hadoop-* rm -f "$HADOOP_LOG_DIR"/* diff --git a/bin/impl/setup-metrics.sh b/bin/impl/setup-metrics.sh index e045ca1..b992a9e 100755 --- a/bin/impl/setup-metrics.sh +++ b/bin/impl/setup-metrics.sh @@ -17,11 +17,11 @@ source "$UNO_HOME"/bin/impl/util.sh if [[ "$OSTYPE" == "darwin"* ]]; then - echo >&0 "The metrics services (InfluxDB and Grafana) are not supported on Mac OS X at this time." + print_to_console "The metrics services (InfluxDB and Grafana) are not supported on Mac OS X at this time." exit 1 fi -echo >&0 "Killing InfluxDB & Grafana (if running)" +print_to_console "Killing InfluxDB & Grafana (if running)" pkill -f influxdb pkill -f grafana-server @@ -35,36 +35,36 @@ verify_exist_hash "$GRAFANA_TARBALL" "$GRAFANA_HASH" INFLUXDB_TARBALL=influxdb-"$INFLUXDB_VERSION".tar.gz GRAFANA_TARBALL=grafana-"$GRAFANA_VERSION".tar.gz if [[ ! -f "$DOWNLOADS/build/$INFLUXDB_TARBALL" ]]; then - echo >&0 "InfluxDB tarball $INFLUXDB_TARBALL does not exists in downloads/build/" + print_to_console "InfluxDB tarball $INFLUXDB_TARBALL does not exists in downloads/build/" exit 1 fi if [[ ! -f "$DOWNLOADS/build/$GRAFANA_TARBALL" ]]; then - echo >&0 "Grafana tarball $GRAFANA_TARBALL does not exists in downloads/build" + print_to_console "Grafana tarball $GRAFANA_TARBALL does not exists in downloads/build" exit 1 fi if [[ ! -d "$FLUO_HOME" ]]; then - echo >&0 "Fluo must be installed before setting up metrics" + print_to_console "Fluo must be installed before setting up metrics" exit 1 fi # stop if any command fails set -e -echo >&0 "Removing previous versions of InfluxDB & Grafana" +print_to_console "Removing previous versions of InfluxDB & Grafana" rm -rf "$INSTALL"/influxdb-* rm -rf "$INSTALL"/grafana-* -echo >&0 "Remove previous log and data dirs" +print_to_console "Remove previous log and data dirs" rm -f "$LOGS_DIR"/metrics/* rm -rf "$DATA_DIR"/influxdb mkdir -p "$LOGS_DIR"/metrics -echo >&0 "Setting up metrics (influxdb + grafana)..." +print_to_console "Setting up metrics (influxdb + grafana)..." tar xzf "$DOWNLOADS/build/$INFLUXDB_TARBALL" -C "$INSTALL" "$INFLUXDB_HOME"/bin/influxd config -config "$UNO_HOME"/conf/influxdb/influxdb.conf > "$INFLUXDB_HOME"/influxdb.conf if [[ ! -f "$INFLUXDB_HOME"/influxdb.conf ]]; then - echo >&0 "Failed to create $INFLUXDB_HOME/influxdb.conf" + print_to_console "Failed to create $INFLUXDB_HOME/influxdb.conf" exit 1 fi $SED "s#DATA_DIR#$DATA_DIR#g" "$INFLUXDB_HOME"/influxdb.conf @@ -79,7 +79,7 @@ cp "$FLUO_HOME"/contrib/grafana/* "$GRAFANA_HOME"/dashboards/ cp "$UNO_HOME"/conf/grafana/accumulo-dashboard.json "$GRAFANA_HOME"/dashboards/ "$GRAFANA_HOME"/bin/grafana-server -homepath="$GRAFANA_HOME" 2> /dev/null & -echo >&0 "Configuring Fluo to send metrics to InfluxDB" +print_to_console "Configuring Fluo to send metrics to InfluxDB" if [[ $FLUO_VERSION =~ ^1\.[0-1].*$ ]]; then FLUO_PROPS=$FLUO_HOME/conf/fluo.properties else @@ -94,14 +94,14 @@ $SED "/fluo.metrics.reporter.graphite/d" "$FLUO_PROPS" echo "fluo.metrics.reporter.graphite.frequency=30" } >> "$FLUO_PROPS" -echo >&0 "Configuring InfluxDB..." +print_to_console "Configuring InfluxDB..." sleep 10 "$INFLUXDB_HOME"/bin/influx -import -path "$FLUO_HOME"/contrib/influxdb/fluo_metrics_setup.txt # allow commands to fail set +e -echo >&0 "Configuring Grafana..." +print_to_console "Configuring Grafana..." sleep 5 @@ -112,11 +112,11 @@ function add_datasource() { --data-binary "$1" retcode=$? if [[ $retcode != 0 ]]; then - echo >&0 "Failed to add Grafana data source. Retrying in 5 sec.." + print_to_console "Failed to add Grafana data source. Retrying in 5 sec.." sleep 5 fi done - echo >&0 "" + print_to_console "" } accumulo_data='{"name":"accumulo_metrics","type":"influxdb","url":"http://' diff --git a/bin/impl/setup-spark.sh b/bin/impl/setup-spark.sh index 3f015f9..46f8b5c 100755 --- a/bin/impl/setup-spark.sh +++ b/bin/impl/setup-spark.sh @@ -19,11 +19,11 @@ source "$UNO_HOME"/bin/impl/util.sh verify_exist_hash "$SPARK_TARBALL" "$SPARK_HASH" if [[ ! -d "$HADOOP_PREFIX" ]]; then - echo >&0 "Apache Hadoop needs to be setup before Apache Spark can be setup." + print_to_console "Apache Hadoop needs to be setup before Apache Spark can be setup." exit 1 fi -echo >&0 "Setting up Apache Spark at $SPARK_HOME" +print_to_console "Setting up Apache Spark at $SPARK_HOME" pkill -f org.apache.spark.deploy.history.HistoryServer diff --git a/bin/impl/setup-zookeeper.sh b/bin/impl/setup-zookeeper.sh index 9a6ef37..c8526db 100755 --- a/bin/impl/setup-zookeeper.sh +++ b/bin/impl/setup-zookeeper.sh @@ -23,7 +23,7 @@ pkill -f QuorumPeerMain # stop if any command fails set -e -echo >&0 "Setting up Apache ZooKeeper at $ZOOKEEPER_HOME" +print_to_console "Setting up Apache ZooKeeper at $ZOOKEEPER_HOME" rm -rf "$INSTALL"/zookeeper-* rm -f "$ZOO_LOG_DIR"/* mkdir -p "$ZOO_LOG_DIR" diff --git a/bin/impl/util.sh b/bin/impl/util.sh index ac1a4fa..dcdc40e 100755 --- a/bin/impl/util.sh +++ b/bin/impl/util.sh @@ -19,7 +19,7 @@ function verify_exist_hash() { expected_hash=$(echo "${2// /}" | tr '[:upper:]' '[:lower:]') if [[ ! -f "$DOWNLOADS/$tarball" ]]; then - echo >&0 "The tarball $tarball does not exist in downloads/" + print_to_console "The tarball $tarball does not exist in downloads/" exit 1 fi @@ -30,14 +30,14 @@ function verify_exist_hash() { 64) HASH_CMD='shasum -a 256' ;; 128) HASH_CMD='shasum -a 512' ;; *) - echo >&0 "Expected checksum ($expected_hash) of $tarball is not an MD5, SHA1, SHA256, or SHA512 sum" + print_to_console "Expected checksum ($expected_hash) of $tarball is not an MD5, SHA1, SHA256, or SHA512 sum" exit 1 ;; esac actual_hash=$($HASH_CMD "$DOWNLOADS/$tarball" | awk '{print $1}') if [[ "$actual_hash" != "$expected_hash" ]]; then - echo >&0 "The actual checksum ($actual_hash) of $tarball does not match the expected checksum ($expected_hash)" + print_to_console "The actual checksum ($actual_hash) of $tarball does not match the expected checksum ($expected_hash)" exit 1 fi } @@ -46,7 +46,7 @@ function verify_exist_hash() { function check_dirs() { for arg in "$@"; do if [[ ! -d "${!arg}" ]]; then - echo >&0 "$arg=${!arg} is not a valid directory. Please make sure it exists" + print_to_console "$arg=${!arg} is not a valid directory. Please make sure it exists" exit 1 fi done @@ -59,3 +59,20 @@ function run_setup_script() { shift "$UNO_HOME/bin/impl/setup-$SCRIP.sh" "$@" 1>"$L_DIR/$SCRIP.stdout" 2>"$L_DIR/$SCRIP.stderr" } + +function save_console_fd { + if [[ -z "$UNO_CONSOLE_FD" ]]; then + # Allocate an unused file descriptor and make it dup stdout + # https://stackoverflow.com/a/41620630/7298689 + exec {UNO_CONSOLE_FD}>&1 + export UNO_CONSOLE_FD + fi +} + +function print_to_console { + if [[ -z "$UNO_CONSOLE_FD" ]]; then + echo "$@" + else + echo "$@" >&${UNO_CONSOLE_FD} + fi +} diff --git a/bin/uno b/bin/uno index 94c74ab..5389b14 100755 --- a/bin/uno +++ b/bin/uno @@ -42,6 +42,7 @@ fetch) setup) [[ -n $LOGS_DIR ]] && rm -f "$LOGS_DIR"/setup/*.std{out,err} echo "Beginning setup (detailed logs in $LOGS_DIR/setup)..." + save_console_fd case "$2" in all) run_setup_script Fluo