1 | var util = require('util');
|
2 | var net = require('net');
|
3 | var repl = require('repl');
|
4 |
|
5 | var replI = module.exports = function (config) {
|
6 | this.config = util.extend(
|
7 | Object.create(replI.defaultConfig),
|
8 | config || {}
|
9 | );
|
10 | this.listen();
|
11 | };
|
12 |
|
13 | replI.defaultConfig = {
|
14 | host: 'localhost',
|
15 | port: 5001,
|
16 | message: 'dataflo.ws$ '
|
17 | };
|
18 |
|
19 | replI.prototype.listen = function () {
|
20 | var config = this.config;
|
21 |
|
22 | console.log('REPL server running on %s:%s', config.host, config.port);
|
23 |
|
24 | net.createServer(function (socket) {
|
25 | repl.start(config.message, socket);
|
26 | }).listen(config.port, config.host);
|
27 | };
|