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
de7e7c4e
Commit
de7e7c4e
authored
Feb 17, 2015
by
Hunter Loftis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests and implementation for WEB_CONCURRENCY
parent
89c56f32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
14 deletions
+78
-14
build.sh
lib/build.sh
+1
-0
concurrency.sh
lib/concurrency.sh
+35
-0
run
test/run
+42
-14
No files found.
lib/build.sh
View file @
de7e7c4e
...
...
@@ -215,6 +215,7 @@ write_profile() {
mkdir
-p
$build_dir
/.profile.d
echo
"export PATH=
\"\$
HOME/.heroku/node/bin:
\$
HOME/bin:
\$
HOME/node_modules/.bin:
\$
PATH
\"
"
>
$build_dir
/.profile.d/nodejs.sh
echo
"export NODE_HOME=
\"\$
HOME/.heroku/node
\"
"
>>
$build_dir
/.profile.d/nodejs.sh
cat
$bp_dir
/lib/concurrency.sh
>>
$build_dir
/.profile.d/nodejs.sh
}
write_export
()
{
...
...
lib/concurrency.sh
0 → 100755
View file @
de7e7c4e
calculate_concurrency
()
{
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
elif
((
WEB_CONCURRENCY
>
32
))
;
then
WEB_CONCURRENCY
=
32
fi
WEB_CONCURRENCY
=
$WEB_CONCURRENCY
}
log_concurrency
()
{
echo
"Detected
$MEMORY_AVAILABLE
MB available memory,
$WEB_MEMORY
MB limit per process (WEB_MEMORY)"
echo
"Recommending WEB_CONCURRENCY=
$WEB_CONCURRENCY
"
}
detect_memory
()
{
local
default
=
$1
local
limit
=
$(
ulimit
-u
)
case
$limit
in
256
)
echo
"512"
;;
512
)
echo
"1024"
;;
32768
)
echo
"6144"
;;
*
)
echo
"
$default
"
;;
esac
}
calculate_concurrency
log_concurrency
export
MEMORY_AVAILABLE
=
$MEMORY_AVAILABLE
export
WEB_MEMORY
=
$WEB_MEMORY
export
WEB_CONCURRENCY
=
$WEB_CONCURRENCY
test/run
View file @
de7e7c4e
...
...
@@ -18,13 +18,6 @@ testDetectWithoutPackageJson() {
assertCapturedError 1
""
}
testUnstableVersion
()
{
compile
"unstable-version"
assertCaptured
"Resolving node version 0.11.x via semver.io"
assertCaptured
"Downloading and installing node 0.11"
assertCapturedSuccess
}
testBadJson
()
{
compile
"bad-json"
assertCaptured
"Build failed"
...
...
@@ -68,13 +61,12 @@ testStableVersion() {
assertCapturedSuccess
}
testUnstableVersion
()
{
compile
"unstable-version"
assertCaptured
"Resolving node version 0.11.x via semver.io"
assertCaptured
"Downloading and installing node 0.11"
assertCapturedSuccess
}
testOldNpm
()
{
compile
"old-npm"
...
...
@@ -366,6 +358,42 @@ testMultiExport() {
assertCapturedSuccess
}
testConcurrency1X
()
{
MEMORY_AVAILABLE
=
512 capture
${
bp_dir
}
/lib/concurrency.sh
assertCaptured
"Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)"
assertCaptured
"Recommending WEB_CONCURRENCY=1"
assertCapturedSuccess
}
testConcurrency2X
()
{
MEMORY_AVAILABLE
=
1024 capture
${
bp_dir
}
/lib/concurrency.sh
assertCaptured
"Detected 1024 MB available memory, 512 MB limit per process (WEB_MEMORY)"
assertCaptured
"Recommending WEB_CONCURRENCY=2"
assertCapturedSuccess
}
testConcurrencyPX
()
{
MEMORY_AVAILABLE
=
6144 capture
${
bp_dir
}
/lib/concurrency.sh
assertCaptured
"Detected 6144 MB available memory, 512 MB limit per process (WEB_MEMORY)"
assertCaptured
"Recommending WEB_CONCURRENCY=12"
assertCapturedSuccess
}
testConcurrencyCustomLimit
()
{
MEMORY_AVAILABLE
=
1024
WEB_MEMORY
=
256 capture
${
bp_dir
}
/lib/concurrency.sh
assertCaptured
"Detected 1024 MB available memory, 256 MB limit per process (WEB_MEMORY)"
assertCaptured
"Recommending WEB_CONCURRENCY=4"
assertCapturedSuccess
}
testConcurrencySaneMaximum
()
{
MEMORY_AVAILABLE
=
6144
WEB_MEMORY
=
32 capture
${
bp_dir
}
/lib/concurrency.sh
assertCaptured
"Detected 6144 MB available memory, 32 MB limit per process (WEB_MEMORY)"
assertCaptured
"Recommending WEB_CONCURRENCY=32"
assertCapturedSuccess
}
# Utils
pushd
$(
dirname
0
)
>
/dev/null
...
...
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