Navigation Menu

Skip to content

Commit

Permalink
Better registering plugins.
Browse files Browse the repository at this point in the history
  • Loading branch information
athoune committed May 30, 2012
1 parent 170f707 commit f1f1f76
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bin/mesures.js
Expand Up @@ -19,22 +19,31 @@ if (args.length) {
conf = {
host: 'localhost',
port: 1337,
plugins: { // [TODO] named arguments
'input/tcp_socket': [8124, 'localhost'],
plugins: {
'input/tcp_socket': {port: 8124, host: 'localhost'},
'state_web': [],
'proc/stats': [],
'output/vapor': []
}
};
}

console.log(conf);

var server = http.createServer();
var router = new Router(server);

server.listen(conf.port, conf.host);

// [TODO] counting registered plugins and trigger a "everybody is ready" call back.
var plugins = 0;
for (var plugin in conf.plugins) {
console.log('[registering]', plugin);
plugins += 1;
var p = require('../lib/' + plugin);
p.register(state, router, conf.plugins[plugin]);
p.register(state, router, conf.plugins[plugin], function() {
plugins -= 1;
if (plugins == 0) {
console.log('[registering] Done !');
}
});
}

0 comments on commit f1f1f76

Please sign in to comment.