Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
29db6b78
Commit
29db6b78
authored
Apr 21, 2017
by
Jeremy Morrell
Committed by
GitHub
Apr 21, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Pad WEB_CONCURRENCY with a leading zero (#389)" (#392)
This reverts commit
dd6a5f5a
.
parent
c59b671e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
27 deletions
+15
-27
nodejs.sh
profile/nodejs.sh
+10
-15
run
test/run
+5
-12
No files found.
profile/nodejs.sh
View file @
29db6b78
calculate_concurrency
()
{
local
memory_available
=
$1
local
web_memory
=
$2
local
concurrency
=
$((
memory_available/web_memory
))
if
((
concurrency < 1
))
;
then
concurrency
=
1
MEMORY_AVAILABLE
=
${
MEMORY_AVAILABLE
-
$(
detect_memory 512
)}
WEB_MEMORY
=
${
WEB_MEMORY
-512
}
WEB_CONCURRENCY
=
${
WEB_CONCURRENCY
-
$((
MEMORY_AVAILABLE/WEB_MEMORY
))}
if
((
WEB_CONCURRENCY < 1
))
;
then
WEB_CONCURRENCY
=
1
fi
# 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
"
WEB_CONCURRENCY
=
$WEB_CONCURRENCY
}
log_concurrency
()
{
...
...
@@ -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_ENV
=
${
NODE_ENV
:-
production
}
export
MEMORY_AVAILABLE
=
${
MEMORY_AVAILABLE
:-$(
detect_memory 512
)}
export
WEB_MEMORY
=
${
WEB_MEMORY
:-
512
}
calculate_concurrency
# if the user hasn't set a value for WEB_CONCURRENCY we compute a reasonable value
export
WEB_CONCURRENCY
=
${
WEB_CONCURRENCY
:-$(
calculate_concurrency
$MEMORY_AVAILABLE
$WEB_MEMORY
)}
export
MEMORY_AVAILABLE
=
$MEMORY_AVAILABLE
export
WEB_MEMORY
=
$WEB_MEMORY
export
WEB_CONCURRENCY
=
$WEB_CONCURRENCY
if
[
"
$LOG_CONCURRENCY
"
=
"true"
]
;
then
log_concurrency
...
...
test/run
View file @
29db6b78
...
...
@@ -223,45 +223,38 @@ testBuildWithUserCacheDirectoriesCamel() {
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
()
{
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
"Recommending WEB_CONCURRENCY=
0
1"
assertCaptured
"Recommending WEB_CONCURRENCY=1"
assertCapturedSuccess
}
testConcurrency2X
()
{
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
"Recommending WEB_CONCURRENCY=
0
2"
assertCaptured
"Recommending WEB_CONCURRENCY=2"
assertCapturedSuccess
}
testConcurrencyPerformanceM
()
{
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
"Recommending WEB_CONCURRENCY=
0
5"
assertCaptured
"Recommending WEB_CONCURRENCY=5"
assertCapturedSuccess
}
testConcurrencyPerformanceL
()
{
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
"Recommending WEB_CONCURRENCY=
0
28"
assertCaptured
"Recommending WEB_CONCURRENCY=28"
assertCapturedSuccess
}
testConcurrencyCustomLimit
()
{
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
"Recommending WEB_CONCURRENCY=
0
4"
assertCaptured
"Recommending WEB_CONCURRENCY=4"
assertCapturedSuccess
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment