Skip to content

Instantly share code, notes, and snippets.

Last active March 24, 2021 02:00
What would you like to do?
lightweight node-websocketd


A lightweight node port of websocketd, originally written in go.


node-websocketd --port=8080 ./
var spawn = require('child_process').spawn;
var Server = require('ws').Server;
var Stream = require('websocket-stream');
var argv = require('optimist').argv;
var server = new Server({ port: argv.port });
server.on('connection', function(ws) {
var stream = Stream(ws);
var ps = spawn(argv._[0], argv._.slice(1));
stream.on('end', ps.kill.bind(ps));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment