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 / 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)
// 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
/* ========================== 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);
});

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

@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
@blakmatrix
blakmatrix / gist:2842259
Created May 31, 2012 09:38
nodejitsu HTTPS test
Bad:
blakmatrix:blakmatrix_http_https_test/ $ curl -k https://blakmatrix-test-http-https.jitsu.com:80 -v [2:27:03]
* About to connect() to blakmatrix-test-http-https.jitsu.com port 80 (#0)
* Trying 108.166.87.26... connected
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to blakmatrix-test-http-https.jitsu.com:80
@blakmatrix
blakmatrix / gist:2932720
Created June 14, 2012 20:23
jitsu deploy hanging on creating snapshot every once in a while
blakmatrix:http-server/ $ jitsu deploy [13:12:43]
info: Welcome to Nodejitsu blakmatrix
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Skipping require-analyzer because noanalyze option is set
info: Skipping require-analyzer because noanalyze option is set
info: Creating snapshot 0.0.4
^C
PS C:\Users\fred rosak\Documents\GitHub\node-migrator-bot> node .\app.js repo "C:\Users\fred rosak\Documents\GitHub\node-backplane"
info: Attempting to open path"C:\Users\fred rosak\Documents\GitHub\node-backplane"
info: C:\Users\fred rosak\Documents\GitHub\node-backplane is a folder
debug: No require('sys') text found in C:\Users\fred rosak\Documents\GitHub\node-backplane\.gitignore, no modifications made.
info: node-migrator-bot ok
debug: No require('sys') text found in C:\Users\fred rosak\Documents\GitHub\node-backplane\cucumber.yml, no modifications made.
info: node-migrator-bot ok
debug: No require('sys') text found in C:\Users\fred rosak\Documents\GitHub\node-backplane\ciConfig.yml, no modifications made.
info: node-migrator-bot ok
debug: No require('sys') text found in C:\Users\fred rosak\Documents\GitHub\node-backplane\LICENSE, no modifications made.
PS C:\Users\fred rosak\projects\vows> vows -i --spec -v
vows bin argv []
vows bin options {
matcher: /.*/,
reporter: 'dot-matrix'
}
vows bin discovering folder structure
vows bin discovered ./test
vows runner loading [
'C:\\Users\\fred rosak\\projects\\vows\\test\\assert-test',
[blakmatrix@li225-26]31 node-migrator-bot:\> cd tmp/eugeniy/opentk-phantom/
[blakmatrix@li225-26]32 opentk-phantom:\> git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
[blakmatrix@li225-26]33 opentk-phantom:\> git branch
[blakmatrix@li225-26]34 opentk-phantom:\> git clone https://github.com/node-migrator-bot/opentk-phantom
Initialized empty Git repository in /home/blakmatrix/projects/node-migrator-bot/tmp/eugeniy/opentk-phantom/opentk-phantom/.git/