Skip to content

Instantly share code, notes, and snippets.

@cho45
Created May 14, 2016 04:50
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 cho45/6e5afb4066e341cf9c55f1f4b3773fe9 to your computer and use it in GitHub Desktop.
Save cho45/6e5afb4066e341cf9c55f1f4b3773fe9 to your computer and use it in GitHub Desktop.
start_server --port=5001 -- node server.js
//#!/usr/bin/env node
"use strict";
const http = require('http');
const server_starter_port = process.env['SERVER_STARTER_PORT'];
if (!server_starter_port) {
console.log('SERVER_STARTER_PORT is not set');
process.exit(1);
}
console.log(server_starter_port);
const fds = server_starter_port.split(/;/).map( (i) => i.split(/=/) );
const server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
for (let fd of fds) {
console.log('listen', fd);
server.listen({ fd: +fd[1] });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment