Created
October 17, 2012 16:15
-
-
Save vvo/3906440 to your computer and use it in GitHub Desktop.
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
// npm install -g shelljs | |
// sudo apt-get install socat | |
require('shelljs/global'); | |
setInterval(function(){ | |
for (var i = 0; i < 10; i++) | |
exec("echo 'process' | socat - UNIX-CONNECT:/tmp/noderepl.sock", {async: true}) | |
}, 10) | |
// shjs client.js |
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 repl = require('repl') | |
var net = require('net') | |
var fs = require('fs') | |
var sockpath = '/tmp/noderepl.sock' | |
process.on('uncaughtException', function(err) { | |
console.log(err.stack) | |
}) | |
fs.unlink(sockpath, function() { | |
net.createServer(function (socket) { | |
var r = repl.start({ | |
prompt: 'yippee ki yay ' | |
, input: socket | |
, output: socket | |
, terminal: true | |
, useGlobal: false | |
}) | |
r.on('exit', function () { | |
socket.end() | |
}) | |
r.context.socket = socket | |
r.context.big = new Buffer(1000) | |
}).listen(sockpath) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment