Permalink
Browse files

Adds Repl example

  • Loading branch information...
1 parent 89dc435 commit 83f7fbc664df00331625cde25e72bfd225bc8a2c Alexander Simmerl committed Jan 10, 2012
Showing with 15 additions and 2 deletions.
  1. +12 −0 example/repl.js
  2. +3 −2 lib/repl.js
View
@@ -0,0 +1,12 @@
+var repl = require('../index').repl;
+
+// Creates the Repl without any customizations
+repl.createRepl();
+
+// Use that PID to start debug server with: kill -31 <PID>
+console.log('PID: %d', process.pid);
+
+ // Keeps the process running
+setInterval(function() {
+ console.log('alive');
+}, 10000);
View
@@ -9,6 +9,7 @@ exports.Repl = Repl;
function Repl(config) {
config = config || {};
+ var that = this;
this.event = config.event || 'SIGUSR2',
this.host = config.host || '0.0.0.0';
this.port = config.port || 9999;
@@ -18,7 +19,7 @@ function Repl(config) {
this._srv.on('connection', this._connectionHandler.bind(this));
this._srv.on('close', function() {
- this._listens = false;
+ that._listens = false;
console.log('Debug server stopped');
});
@@ -38,7 +39,7 @@ Repl.prototype._eventHandler = function() {
this._srv.close();
} else {
this._srv.listen(this.port, this.host, function() {
- this._listens = true;
+ that._listens = true;
console.log('Debug server listening on %s:%d', that.host, that.port);
});

0 comments on commit 83f7fbc

Please sign in to comment.