Skip to content

Instantly share code, notes, and snippets.

Farrin Reid blakmatrix

Block or report user

Report or block blakmatrix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@blakmatrix
blakmatrix / gist:c7907607272fcd016ccf
Created Apr 24, 2015
Passenger-Docker (Phusion Passenger version: 5.0.6) - Process aborted! signo=SIGSEGV(11), reason=SEGV_MAPERR
View gist:c7907607272fcd016ccf
[ 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
View gist:6a8a9c5aa9357dc42cf3

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

View user.js
/* ========================== 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);
});
View graceful.js
// 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 Apr 10, 2014
TAP testing methods and aliases
View taps.js
assert (ok, message, extra)
[ "true", "assert" ]
notOk (ok, message, extra)
[ "ifError", "ifErr", "iferror" ]
pass (message, extra)
View Arduino Song
**/
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;
View node0.10.0.ps1
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
View gist:5136225
$ 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)
View gist:5052275
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> '
View gist:5051225
~/test/node-sass]# node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@0.8.4
gyp info using node@0.8.19 | 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',
You can’t perform that action at this time.