Skip to content

Instantly share code, notes, and snippets.

View adamrights's full-sized avatar

Adam Bedell adamrights

View GitHub Profile
#!/bin/bash
#source env variables including node version
. /opt/elasticbeanstalk/env.vars
function error_exit
{
eventHelper.py --msg "$1" --severity ERROR
exit $2
}
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml" itemscope="itemscope" itemtype="http://schema.org/Product"><head ng-controller="MetaCtrl" class="ng-scope"><style type="text/css">@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide{display:none !important;}ng\:form{display:block;}.ng-animate-start{clip:rect(0,auto,auto,0);-ms-zoom:1.0001;}.ng-animate-active{clip:rect(-1px,auto,auto,0);-ms-zoom:1;}</style>
<meta charset="utf-8">
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<!--facebook-->
<meta property="fb:app_id" content="432013823568121">
<!-- put og tags here-->
<!-- tealium:-->
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ];
then
GIT_AUTHOR_NAME="Scott Chacon";
GIT_AUTHOR_EMAIL="[email protected]";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
/*
* Cheerio, A test for crawling anchors on a site.
*/
var request = require('request');
var cheerio = require('cheerio');
var async = require('async');
var jar = request.jar();
request({
var json = {
encode: JSON.stringify,
decode: JSON.parse
};
var MsgPack = require('node-msgpack');
msgpack = {
encode: MsgPack.pack,
decode: function(str) { return MsgPack.unpack(new Buffer(str)); }
};
describe("DOM Tests", function () {
var el = document.createElement("div");
el.id = "myDiv";
el.innerHTML = "Hi there!";
el.style.background = "#ccc";
document.body.appendChild(el);
var myEl = document.getElementById('myDiv');
it("is in the DOM", function () {
expect(myEl).not.toBeNull();
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.
cluster.fork();
cluster.fork();
cluster.on('disconnect', function(worker) {
@adamrights
adamrights / app.js
Created February 3, 2014 10:14 — forked from nulltask/app.js
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, cluster = require('cluster');
var app = module.exports = express.createServer()
, io = require('./socket')(app);

Clustering: The basics

The trick? pass the file descriptor from a parent process and have the server.listen reuse that descriptor. So multiprocess in their own memory space (but with ENV shared usually)

It does not balance, it leaves it to the kernel.

In the last nodejs > 0.8 there is a cluster module (functional although marked experimental)

{_} = require 'underscore'
child_process = require 'child_process'
async = require 'async'
healthCheckInterval = 60 * 1000
bounceInterval = 60 * 1000
bounceWait = bounceInterval + 30 * 1000
delayTimeout = (ms, func) -> setTimeout func, ms
class MonitoredChild