Skip to content

Commit

Permalink
Add the --fd parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Aug 22, 2014
1 parent fed4501 commit 3865141
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ lib-cov
config/dev.json
config/stage.json
config/prod.json
circus/*.log
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ loadtests-check:
sleep 1 && cd loadtests && \
make test SERVER_URL=http://127.0.0.1:5000; \
EXIT_CODE=$$?; kill $$PID; exit $$EXIT_CODE

.PHONY: circus
circus:
circusd circus/loop-server.ini
27 changes: 27 additions & 0 deletions circus/loop-server.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557

[plugin:flapping]
use = circus.plugins.flapping.Flapping
retry_in = 3
max_retry = 2

[watcher:loop]
cmd = node loop/index.js --fd $(circus.sockets.loop)
use_sockets = True
warmup_delay = 0
numprocesses = 2
stop_children = true
stop_signal = SIGINT
stdout_stream.class = StdoutStream
stderr_stream.class = StdoutStream

[socket:loop]
host = 127.0.0.1
port = 5000

[env:loop]
NODE_ENV = dev
15 changes: 11 additions & 4 deletions loop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,19 @@ pushServerConfig(app, conf);
app.use(raven.middleware.express(conf.get('sentryDSN')));

// Starts HTTP server.
var argv = require('yargs').argv;
var server = http.createServer(app);
server.listen(conf.get('port'), conf.get('host'), function(){
console.log('Server listening on http://' +
conf.get('host') + ':' + conf.get('port'));
});

if (argv.hasOwnProperty("fd")) {
server.listen({fd: parseInt(argv.fd, 10)}, function() {
console.log("Server listening on fd://" + argv.fd);
});
} else {
server.listen(conf.get('port'), conf.get('host'), function(){
console.log('Server listening on http://' +
conf.get('host') + ':' + conf.get('port'));
});
}

// Handle websockets.
var ws = websockets(storage, logError, conf);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"sodium": "1.0.11",
"atob": "1.1.2",
"express-hawkauth": "0.2.0",
"eslint": "0.7.x"
"eslint": "0.7.x",
"yargs": "1.3.1"
},
"devDependencies": {
"chai": "1.9.x",
Expand Down

0 comments on commit 3865141

Please sign in to comment.