Created
May 14, 2016 04:50
-
-
Save cho45/6e5afb4066e341cf9c55f1f4b3773fe9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
start_server --port=5001 -- node server.js |
This file contains hidden or 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
//#!/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