Skip to content

Instantly share code, notes, and snippets.

@vvo
Created October 17, 2012 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vvo/3906440 to your computer and use it in GitHub Desktop.
Save vvo/3906440 to your computer and use it in GitHub Desktop.
// 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
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