This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git is needed for npm if you have git references | |
build-essential: | |
pkg: | |
- installed | |
npm-custom: | |
git.latest: | |
- name: https://github.com/isaacs/npm.git | |
- target: /opt/npm | |
- rev: v1.4.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# roles/openssl/files/install.sh | |
wget https://www.openssl.org/source/openssl-1.0.1g.tar.gz -O /tmp/openssl-1.0.1g.tar.gz | |
cd /tmp | |
tar -xvzf openssl-1.0.1g.tar.gz | |
cd openssl-1.0.1g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
TIME=30 | |
# trap ctrl-c and call ctrl_c() | |
trap ctrl_c INT | |
function ctrl_c() { | |
echo + Stopping service 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start on starting gitter-web ## The parent upstart service, so we can start and stop groups together | |
stop on stopping gitter-web | |
# Respawn, but no too much | |
respawn | |
respawn limit 10 5 | |
# Give the process 20 seconds to shutdown properly before resorting to SIGKILL | |
kill timeout 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require() some stuff from npm (like you were using browserify) | |
// and then hit Rebuild to run it on the right | |
var b = require('backbone') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Start a server | |
var Faye = require('faye'), | |
server = new Faye.NodeAdapter({mount: '/'}); | |
server.listen(8000); | |
// Create a client and subscribe to a channel | |
var client = new Faye.Client('http://localhost:8000/'); | |
client.subscribe('/messages', function(message) { alert('Got a message: ' + message.text); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fayeServer = new faye.NodeAdapter({mount: '/faye', timeout: 45}); | |
fayeServer.attach(httpServer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method will send realtime notifications to the faye clients | |
function notifyClients(method, model, url) { | |
bayeux.getClient().publish(url, { | |
method: method, | |
body: model.toJSON() | |
}); | |
} | |
// Attach events to the mongoose schema. Since the default mongoose middleware makes it difficult to | |
// distinguish between a create and an update event, we use a small utility that helps us to do that. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fayeClient = new Faye.Client('/faye'); | |
var LiveCollection = Backbone.Collection.extend({ | |
constructor: function(models, options) { | |
Backbone.Collection.prototype.constructor.call(this, models, options); | |
this.subscription = fayeClient.subscribe(this.url, this._fayeEvent, this); | |
}, | |
_fayeEvent: function(message) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LiveCollection = Backbone.Collection.extend({ | |
... | |
_createEvent: function(body) { | |
... | |
// Look to see if this collection has any outstanding creates... | |
var idAttribute = this.model.prototype.idAttribute; | |
var unsaved = this.filter(function(model) { | |
return !model.id; |
OlderNewer