Skip to content

Commit

Permalink
prevent redundant messages when loading HHVM configs
Browse files Browse the repository at this point in the history
prepare_hhvm_ini is called twice, and the second time around, some of the variables already exist, so it'll print messages that are redundant because the variable values are not user supplied and we're not in verbose mode
  • Loading branch information
dzuelke committed Feb 6, 2015
1 parent 6fc9de5 commit 5bb2832
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions bin/heroku-hhvm-apache2
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ if [[ "$#" == "1" ]]; then
fi
fi

function prepare_hhvm_ini() { # we have to do this twice, as the WEB_CONCURRENCY setting is evaluated using PHP code, not ${...} syntax which HHVM does not support
if [[ -n ${php_config:-} || ( ${php_config:="$HEROKU_APP_DIR/$COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/hhvm/php.ini.php"} && $verbose ) ]]; then
function prepare_hhvm_ini() { # we have to do this twice, as the WEB_CONCURRENCY setting is evaluated using PHP code, not ${...} syntax which HHVM does not support; if a value for $1 is passed then it won't echo messages upon second invocation
if [[ ( -n ${php_config:-} && ! ${1:-} ) || ( ${php_config:="$HEROKU_APP_DIR/$COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/hhvm/php.ini.php"} && $verbose && ! ${1:-} ) ]]; then
echo "Using HHVM configuration (php.ini) file '${php_config#$HEROKU_APP_DIR/}'" >&2
fi
php_configs=( "-c" "$(php_passthrough "$php_config")" )

if [[ -n ${hhvm_config_extra:-} ]]; then
echo "Using additional HHVM configuration (php.ini) file '${hhvm_config_extra#$HEROKU_APP_DIR/}'" >&2
[[ ${1:-} ]] || echo "Using additional HHVM configuration (php.ini) file '${hhvm_config_extra#$HEROKU_APP_DIR/}'" >&2
php_configs+=( "-c" "$(php_passthrough "$hhvm_config_extra")" )
fi
}
Expand Down Expand Up @@ -273,8 +273,8 @@ else
echo "Running ${WEB_CONCURRENCY} threads as per \$WEB_CONCURRENCY" >&2
fi

# we changed WEB_CONCURRENCY; now we need to re-evaluate the configs as HHVM doesn't support ${...} syntax, so the configs contain PHP getenv() calls and are templated
prepare_hhvm_ini
# we changed WEB_CONCURRENCY; now we need to re-evaluate the configs as HHVM doesn't support ${...} syntax, so the configs contain PHP getenv() calls and are templated; we pass an argument to it to avoid it echoing "using HHVM config ..." messages again because that already happened
prepare_hhvm_ini no_messages

# make a shared pipe; we'll write the name of the process that exits to it once that happens, and wait for that event below
# this particular call works on Linux and Mac OS (will create a literal ".XXXXXX" on Mac, but that doesn't matter).
Expand Down
10 changes: 5 additions & 5 deletions bin/heroku-hhvm-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ if [[ "$#" == "1" ]]; then
fi
fi

function prepare_hhvm_ini() { # we have to do this twice, as the WEB_CONCURRENCY setting is evaluated using PHP code, not ${...} syntax which HHVM does not support
if [[ -n ${php_config:-} || ( ${php_config:="$HEROKU_APP_DIR/$COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/hhvm/php.ini.php"} && $verbose ) ]]; then
function prepare_hhvm_ini() { # we have to do this twice, as the WEB_CONCURRENCY setting is evaluated using PHP code, not ${...} syntax which HHVM does not support; if a value for $1 is passed then it won't echo messages upon second invocation
if [[ ( -n ${php_config:-} && ! ${1:-} ) || ( ${php_config:="$HEROKU_APP_DIR/$COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/hhvm/php.ini.php"} && $verbose && ! ${1:-} ) ]]; then
echo "Using HHVM configuration (php.ini) file '${php_config#$HEROKU_APP_DIR/}'" >&2
fi
php_configs=( "-c" "$(php_passthrough "$php_config")" )

if [[ -n ${hhvm_config_extra:-} ]]; then
echo "Using additional HHVM configuration (php.ini) file '${hhvm_config_extra#$HEROKU_APP_DIR/}'" >&2
[[ ${1:-} ]] || echo "Using additional HHVM configuration (php.ini) file '${hhvm_config_extra#$HEROKU_APP_DIR/}'" >&2
php_configs+=( "-c" "$(php_passthrough "$hhvm_config_extra")" )
fi
}
Expand Down Expand Up @@ -273,8 +273,8 @@ else
echo "Running ${WEB_CONCURRENCY} threads as per \$WEB_CONCURRENCY" >&2
fi

# we changed WEB_CONCURRENCY; now we need to re-evaluate the configs as HHVM doesn't support ${...} syntax, so the configs contain PHP getenv() calls and are templated
prepare_hhvm_ini
# we changed WEB_CONCURRENCY; now we need to re-evaluate the configs as HHVM doesn't support ${...} syntax, so the configs contain PHP getenv() calls and are templated; we pass an argument to it to avoid it echoing "using HHVM config ..." messages again because that already happened
prepare_hhvm_ini no_messages

# make a shared pipe; we'll write the name of the process that exits to it once that happens, and wait for that event below
# this particular call works on Linux and Mac OS (will create a literal ".XXXXXX" on Mac, but that doesn't matter).
Expand Down

0 comments on commit 5bb2832

Please sign in to comment.