Skip to content

Instantly share code, notes, and snippets.

View blakmatrix's full-sized avatar
🧿
You may be gone tomorrow, but that doesn't mean that you weren't here today.

❤️ Farrin Reid blakmatrix

🧿
You may be gone tomorrow, but that doesn't mean that you weren't here today.
View GitHub Profile
@blakmatrix
blakmatrix / gist:c7907607272fcd016ccf
Created April 24, 2015 02:29
Passenger-Docker (Phusion Passenger version: 5.0.6) - Process aborted! signo=SIGSEGV(11), reason=SEGV_MAPERR
[ 2015-04-24 02:00:33.5650 356/7f878b7fe700 Ser/AcceptLoadBalancer.h:193 ]: File descriptor opened: 30
[ 2015-04-24 02:00:33.5651 356/7f878b7fe700 Ser/AcceptLoadBalancer.h:135 ]: Accepted client file descriptor: 30
[ 2015-04-24 02:00:33.5651 356/7f878b7fe700 Ser/AcceptLoadBalancer.h:193 ]: File descriptor opened: -1
[ 2015-04-24 02:00:33.5651 356/7f878b7fe700 Ser/AcceptLoadBalancer.h:163 ]: Feeding client to server thread 2: file descriptor 30
[ 2015-04-24 02:00:33.5653 356/7f87a97cc700 age/Hel/Req/TurboCaching.h:242 ]: Clearing turbocache
[ 2015-04-24 02:00:33.5653 356/7f87a97cc700 Ser/Server.h:366 ]: [ServerThr.3] Checking out client object from freelist (128 -> 127)
[ 2015-04-24 02:00:33.5653 356/7f87a97cc700 Ser/Server.h:637 ]: [Client 3-52] Client associated with file descriptor: 30
[ 2015-04-24 02:00:33.5654 356/7f87a97cc700 Ser/Server.h:788 ]: File descriptor purpose: 30: Server ServerThr.3, client 3-52
[ 2015-04-24 02:00:33.5654 356/7f87a97cc700 Ser/Server.h:792 ]: [ServerThr.3] 1 new client(s) accept

Overview

We run multiple server processes in two data centers. Each process listens on two ports, one for HTTP and one for HTTPS. HTTPS is terminated by Apache prior to reaching node.js. HTTP goes directly from the client to node.js (through a master load balancer). We do not use clusters. We slice our physical servers into thin virtual machines running SmartOS, each with about 3GB of memory designed for a single node.js process.

Our node.js servers are hapi.js servers using the composer functionality and plugins architecture. We have three sets of plugins loaded: mobile web front end experience (single page app), legacy API reverse proxy, and monitoring.

We also serve original node.js services off another server zone which runs closed source plugins using hapi.

Analytics

/* ========================== user.create =========================== */
UserModel.prototype.create = function (request, reply, callback) {
var query = user.insert(request.payload).toQuery();
request.postgres.client.query(query.text, query.values, function(err, result) {
if(err) {
console.dir(err);
return callback(Hapi.error.badRequest(err));
}
callback(null, result);
});
// Much better!
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
//
// You can also of course get a bit fancier about logging, and
@blakmatrix
blakmatrix / taps.js
Created April 10, 2014 21:39
TAP testing methods and aliases
assert (ok, message, extra)
[ "true", "assert" ]
notOk (ok, message, extra)
[ "ifError", "ifErr", "iferror" ]
pass (message, extra)
**/
const int c = 261;
const int d = 294;
const int e = 329;
const int f = 349;
const int g = 391;
const int gS = 415;
const int a = 440;
const int aS = 455;
@blakmatrix
blakmatrix / node0.10.0.ps1
Last active December 15, 2015 05:29
jitsu @ 0.12.8
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS C:\Users\fred rosak> cd c:/jitsu
PS C:\jitsu> node -v
v0.10.0
PS C:\jitsu> npm -v
1.2.14
PS C:\jitsu> npm test
$ jitsu [10:53:28]
info: Welcome to Nodejitsu blakmatrix
info: jitsu v0.12.3, node v0.10.0
info: It worked if it ends with Nodejitsu ok
info: Executing command
TypeError: Arguments to path.join must be strings
at path.js:360:15
at Array.filter (native)
at Object.exports.join (path.js:358:36)
var http = require('http'),
repl = require('repl'),
buf0 = new Buffer([0]);
var server = http.createServer(function (req, res) {
res.setHeader('content-type', 'multipart/octet-stream');
res.write('Welcome to the Fun House\r\n');
repl.start({
prompt: 'curl repl> '
~/test/node-sass]# node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | sunos | x64
gyp http GET http://nodejs.org/dist/v0.8.19/node-v0.8.19.tar.gz
gyp http 200 http://nodejs.org/dist/v0.8.19/node-v0.8.19.tar.gz
gyp info spawn python
gyp info spawn args [ '/opt/local/lib/node_modules/node-gyp/gyp/gyp',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',