Skip to content

Instantly share code, notes, and snippets.

@hatchan
Last active December 30, 2015 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatchan/7893099 to your computer and use it in GitHub Desktop.
Save hatchan/7893099 to your computer and use it in GitHub Desktop.
var Hapi = require("hapi");
// Create a server with a host, port, and options
var server = new Hapi.Server("0.0.0.0", 3000);
// Add a route
server.addRoute({
"method": "GET",
"path": "/hello",
"config": {
"handler": function (request) {
console.log("Received call!");
request.reply({ "greeting": "hello world" });
}
}
});
// Start the server
server.start(function() {
console.log("Listening on: " + server.info.uri);
});
=============== Phusion Passenger Standalone web server started ===============
PID file: /var/local/sites/nodejs-capistrano-phusion-sample/tmp/pids/passenger.3000.pid
Log file: /var/local/sites/nodejs-capistrano-phusion-sample/log/passenger.3000.log
Environment: development
Accessible via: http://0.0.0.0:3000/
You can stop Phusion Passenger Standalone by pressing Ctrl-C.
Problems? Check http://www.modrails.com/documentation/Users%20guide%20Standalone.html#troubleshooting
===============================================================================
[ 2013-12-10 15:21:51.3344 20319/7f59fe6f1700 Pool2/Spawner.h:796 ]: [App 20354 stdout]
[ 2013-12-10 15:21:51.9642 20319/7f59fe6f1700 Pool2/Spawner.h:796 ]: [App 20354 stdout] 0.6361726166214794
[ 2013-12-10 15:21:51.9683 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr]
[ 2013-12-10 15:21:51.9692 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] /var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/lib/server.js:319
[ 2013-12-10 15:21:51.9694 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] self.info.port = address.port;
[ 2013-12-10 15:21:51.9696 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] ^
[ 2013-12-10 15:21:51.9718 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] TypeError: Cannot read property 'port' of null
[ 2013-12-10 15:21:51.9720 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at Server.<anonymous> (/var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/lib/server.js:319:37)
[ 2013-12-10 15:21:51.9721 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at Server.g (events.js:175:14)
[ 2013-12-10 15:21:51.9722 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at Server.EventEmitter.emit (events.js:92:17)
[ 2013-12-10 15:21:51.9724 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at Server.installServer [as listen] (/usr/share/passenger/helper-scripts/node-loader.js:151:10)
[ 2013-12-10 15:21:51.9725 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at internals.Server._start (/var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/lib/server.js:343:23)
[ 2013-12-10 15:21:51.9726 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at /var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/lib/pack.js:670:14
[ 2013-12-10 15:21:51.9727 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at iterate (/var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/node_modules/async/lib/async.js:131:13)
[ 2013-12-10 15:21:51.9728 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at Object.async.eachSeries (/var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/node_modules/async/lib/async.js:147:9)
[ 2013-12-10 15:21:51.9729 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at internals.Pack._apply (/var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/lib/pack.js:668:11)
[ 2013-12-10 15:21:51.9730 20319/7f59fe732700 Pool2/Implementation.cpp:1291 ]: [App 20354 stderr] at /var/local/sites/nodejs-capistrano-phusion-sample/node_modules/hapi/lib/pack.js:627:14
2013/12/10 15:21:51 [error] 20335#0: *4 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: _, request: "HEAD / HTTP/1.1", upstream: "passenger:/tmp/passenger.1.0.20315/generation-0/request:", host: "0.0.0.0"
[ 2013-12-10 15:21:52.2976 20319/7f59fe7d5700 Pool2/Pool.h:717 ]: Process (pid=20354, group=/var/local/sites/nodejs-capistrano-phusion-sample#default) no longer exists! Detaching it from the pool.
{
"name": "nodejs-capistrano-phusion-sample",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "bvdberg",
"license": "MIT",
"private": true,
"engine": {
"node": ">=0.10.0"
},
"dependencies": {
"hapi": "~1.20.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment