Skip to content

Commit

Permalink
Autosize v8 heap
Browse files Browse the repository at this point in the history
Also expose $NPM_CLI_OPTIONS for customizing npm
  • Loading branch information
Carlo Alberto Ferraris authored and Carlo Alberto Ferraris committed Apr 18, 2017
1 parent 41482ab commit 4e1c9c7
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.32
1.5.32-1492485633
2 changes: 1 addition & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
cat << EOF
addons: []
default_process_types:
web: npm start
web: npm start --max-old-space-size=$(( $(jq -r '.limits.mem' <<<"$VCAP_APPLICATION") * 75 / 100 )) $NPM_CLI_OPTIONS
EOF
1 change: 1 addition & 0 deletions cf_spec/fixtures/without_procfile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
1 change: 1 addition & 0 deletions cf_spec/fixtures/without_procfile/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ca=
1 change: 1 addition & 0 deletions cf_spec/fixtures/without_procfile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file here to suppress "npm WARN package.json node_web_app@0.0.0 No README data"
22 changes: 22 additions & 0 deletions cf_spec/fixtures/without_procfile/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "node_web_app",
"version": "0.0.0",
"description": "hello, world",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD-2-Clause",
"dependencies": {
"logfmt": "~1.1.2",
"express": "~4.0.0"
},
"engines" : {
},
"repository" :
{
"type" : "git",
"url" : "http://github.com/cloudfoundry/nodejs-buildpack.git"
}
}
4 changes: 4 additions & 0 deletions cf_spec/fixtures/without_procfile/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -l

rm -rf node_modules
npm install
1 change: 1 addition & 0 deletions cf_spec/fixtures/without_procfile/resolve
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.10.26
18 changes: 18 additions & 0 deletions cf_spec/fixtures/without_procfile/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// web.js

console.log("***************************I'm running!********************************")

var express = require("express");
var logfmt = require("logfmt");
var app = express();

app.use(logfmt.requestLogger());

app.get('/', function(req, res) {
res.send('Hello, World!');
});

var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
console.log("Listening on " + port);
});
22 changes: 22 additions & 0 deletions cf_spec/integration/deploy_a_node_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@
end
end

context 'with no Procfile and no NPM_CLI_OPTIONS env var' do
let (:app_name) { 'without_procfile' }

it 'is running with autosized max_old_space_size' do
expect(app).to be_running
expect(app).to have_logged("--max_old_space_size=768")
end
end

context 'with no Procfile and with NPM_CLI_OPTIONS env var' do
let (:app_name) { 'without_procfile' }

subject(:app) do
Machete.deploy_app(app_name, env: {'NPM_CLI_OPTIONS' => '--trace-sync-io'})
end

it 'is running with autosized max_old_space_size and appended NPM_CLI_OPTIONS' do
expect(app).to be_running
expect(app).to have_logged("--max_old_space_size=768 --trace-sync-io")
end
end

context 'with an app that has vendored dependencies' do
let(:app_name) { 'vendored_dependencies' }

Expand Down

0 comments on commit 4e1c9c7

Please sign in to comment.