Commit 29db6b78 authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Revert "Pad WEB_CONCURRENCY with a leading zero (#389)" (#392)

This reverts commit dd6a5f5a.
parent c59b671e
calculate_concurrency() { calculate_concurrency() {
local memory_available=$1 MEMORY_AVAILABLE=${MEMORY_AVAILABLE-$(detect_memory 512)}
local web_memory=$2 WEB_MEMORY=${WEB_MEMORY-512}
local concurrency=$((memory_available/web_memory)) WEB_CONCURRENCY=${WEB_CONCURRENCY-$((MEMORY_AVAILABLE/WEB_MEMORY))}
if (( WEB_CONCURRENCY < 1 )); then
if (( concurrency < 1 )); then WEB_CONCURRENCY=1
concurrency=1
fi fi
WEB_CONCURRENCY=$WEB_CONCURRENCY
# We prepend the calculated value with a leading '0' so that other buildpacks
# can distinguish between a value set by the Node buildpack and a value set
# by the user
echo "0$concurrency"
} }
log_concurrency() { log_concurrency() {
...@@ -35,11 +30,11 @@ export PATH="$HOME/.heroku/node/bin:$HOME/.heroku/yarn/bin:$PATH:$HOME/bin:$HOME ...@@ -35,11 +30,11 @@ export PATH="$HOME/.heroku/node/bin:$HOME/.heroku/yarn/bin:$PATH:$HOME/bin:$HOME
export NODE_HOME="$HOME/.heroku/node" export NODE_HOME="$HOME/.heroku/node"
export NODE_ENV=${NODE_ENV:-production} export NODE_ENV=${NODE_ENV:-production}
export MEMORY_AVAILABLE=${MEMORY_AVAILABLE:-$(detect_memory 512)} calculate_concurrency
export WEB_MEMORY=${WEB_MEMORY:-512}
# if the user hasn't set a value for WEB_CONCURRENCY we compute a reasonable value export MEMORY_AVAILABLE=$MEMORY_AVAILABLE
export WEB_CONCURRENCY=${WEB_CONCURRENCY:-$(calculate_concurrency $MEMORY_AVAILABLE $WEB_MEMORY)} export WEB_MEMORY=$WEB_MEMORY
export WEB_CONCURRENCY=$WEB_CONCURRENCY
if [ "$LOG_CONCURRENCY" = "true" ]; then if [ "$LOG_CONCURRENCY" = "true" ]; then
log_concurrency log_concurrency
......
...@@ -223,45 +223,38 @@ testBuildWithUserCacheDirectoriesCamel() { ...@@ -223,45 +223,38 @@ testBuildWithUserCacheDirectoriesCamel() {
assertCapturedSuccess assertCapturedSuccess
} }
testConcurrencyExplicit() {
LOG_CONCURRENCY=true MEMORY_AVAILABLE=1024 WEB_MEMORY=256 WEB_CONCURRENCY=3 capture $(pwd)/profile/nodejs.sh
assertCaptured "Detected 1024 MB available memory, 256 MB limit per process (WEB_MEMORY)"
assertCaptured "Recommending WEB_CONCURRENCY=3"
assertCapturedSuccess
}
testConcurrency1X() { testConcurrency1X() {
LOG_CONCURRENCY=true MEMORY_AVAILABLE=512 capture $(pwd)/profile/nodejs.sh LOG_CONCURRENCY=true MEMORY_AVAILABLE=512 capture $(pwd)/profile/nodejs.sh
assertCaptured "Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)" assertCaptured "Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)"
assertCaptured "Recommending WEB_CONCURRENCY=01" assertCaptured "Recommending WEB_CONCURRENCY=1"
assertCapturedSuccess assertCapturedSuccess
} }
testConcurrency2X() { testConcurrency2X() {
LOG_CONCURRENCY=true MEMORY_AVAILABLE=1024 capture $(pwd)/profile/nodejs.sh LOG_CONCURRENCY=true MEMORY_AVAILABLE=1024 capture $(pwd)/profile/nodejs.sh
assertCaptured "Detected 1024 MB available memory, 512 MB limit per process (WEB_MEMORY)" assertCaptured "Detected 1024 MB available memory, 512 MB limit per process (WEB_MEMORY)"
assertCaptured "Recommending WEB_CONCURRENCY=02" assertCaptured "Recommending WEB_CONCURRENCY=2"
assertCapturedSuccess assertCapturedSuccess
} }
testConcurrencyPerformanceM() { testConcurrencyPerformanceM() {
LOG_CONCURRENCY=true MEMORY_AVAILABLE=2560 capture $(pwd)/profile/nodejs.sh LOG_CONCURRENCY=true MEMORY_AVAILABLE=2560 capture $(pwd)/profile/nodejs.sh
assertCaptured "Detected 2560 MB available memory, 512 MB limit per process (WEB_MEMORY)" assertCaptured "Detected 2560 MB available memory, 512 MB limit per process (WEB_MEMORY)"
assertCaptured "Recommending WEB_CONCURRENCY=05" assertCaptured "Recommending WEB_CONCURRENCY=5"
assertCapturedSuccess assertCapturedSuccess
} }
testConcurrencyPerformanceL() { testConcurrencyPerformanceL() {
LOG_CONCURRENCY=true MEMORY_AVAILABLE=14336 capture $(pwd)/profile/nodejs.sh LOG_CONCURRENCY=true MEMORY_AVAILABLE=14336 capture $(pwd)/profile/nodejs.sh
assertCaptured "Detected 14336 MB available memory, 512 MB limit per process (WEB_MEMORY)" assertCaptured "Detected 14336 MB available memory, 512 MB limit per process (WEB_MEMORY)"
assertCaptured "Recommending WEB_CONCURRENCY=028" assertCaptured "Recommending WEB_CONCURRENCY=28"
assertCapturedSuccess assertCapturedSuccess
} }
testConcurrencyCustomLimit() { testConcurrencyCustomLimit() {
LOG_CONCURRENCY=true MEMORY_AVAILABLE=1024 WEB_MEMORY=256 capture $(pwd)/profile/nodejs.sh LOG_CONCURRENCY=true MEMORY_AVAILABLE=1024 WEB_MEMORY=256 capture $(pwd)/profile/nodejs.sh
assertCaptured "Detected 1024 MB available memory, 256 MB limit per process (WEB_MEMORY)" assertCaptured "Detected 1024 MB available memory, 256 MB limit per process (WEB_MEMORY)"
assertCaptured "Recommending WEB_CONCURRENCY=04" assertCaptured "Recommending WEB_CONCURRENCY=4"
assertCapturedSuccess assertCapturedSuccess
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment