From fed3ed1868f82b9f5dfeb0d282409cca20388294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Buscht=C3=B6ns?= Date: Wed, 9 Jan 2013 14:28:27 +0100 Subject: [PATCH 1/2] Update Readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index be18682..872761d 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,11 @@ The `up` command accepts the following options: - The port to listen on. Not required if the module already `listen`s. - Defaults to `3000`. +- `-s`/`--socketpath` + + - The unix domain socket path to listen on. Not required if the module already `listen`s. + - Cannot be set, if `port` is specified. + - `-w`/`--watch` - Whether to watch for changes. From 608e625c332b9422638bbc8fe9c10ef903da6cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Buscht=C3=B6ns?= Date: Wed, 9 Jan 2013 14:36:34 +0100 Subject: [PATCH 2/2] Include socket path logic in binary --- bin/up | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/up b/bin/up index 9bf8925..3451aa0 100755 --- a/bin/up +++ b/bin/up @@ -35,7 +35,8 @@ var cpus = require('os').cpus().length; program .version(up.version) .usage('[options] ') - .option('-p, --port ', 'Port to listen on.', 3000) + .option('-p, --port ', 'Port to listen on.') + .option('-s, --socketpath ', 'Unix domain socketpath to listen on.') .option('-T, --title ', 'Process title.', 'up') .option('-f, --pidfile <pidfile>', 'Write port to pidfile') .option('-w, --watch', 'Watch the module directory for changes.') @@ -108,12 +109,20 @@ if (!(server instanceof http.Server)) { var port; +if (null != program.port && null != program.socketpath) { + error('\n Cannot specify both port and socketpath'); +} + if (null != program.port) { port = Number(program.port); if (!port || isNaN(port)) { error('\n Invalid port "%s" (%d).\n', program.port, program.port); } +} else if (null != program.socketpath) { + port = program.socketpath; +} else { + port = 3000; } /** @@ -148,11 +157,15 @@ var keepAlive = program.keepalive; * Start! */ -debug('starting cluster with %d workers on port %d', numWorkers, port); +if (typeof port == "number") { + debug('starting cluster with %d workers on port %d', numWorkers, port); +} else { + debug('starting cluster with %d workers on socket path %s', numWorkers, port); +} debug('`\033[97mkill -s SIGUSR2 %d\033[90m` or \033[97mctrl + r\033[90m' + ' to load new code', process.pid); -var httpServer = http.Server().listen(program.port) +var httpServer = http.Server().listen(port) , srv = up(httpServer, file, { numWorkers: numWorkers , workerTimeout: workerTimeout