Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5 from natevw/cmdline

Basic implementation of CLI utility, just a couple options
  • Loading branch information...
commit 199dbf0d6e4d298b9efa4279c1415616485b38c1 2 parents 8a42690 + ffaef6b
@janl janl authored
Showing with 34 additions and 5 deletions.
  1. +29 −3 bin/multicouch
  2. +5 −2 package.json
View
32 bin/multicouch
@@ -1,4 +1,30 @@
#!/usr/bin/env node
-var MultiCouch = require("../lib/multicouch");
-var my_couch = new MultiCouch({});
-my_couch.stop();
+
+var mc = require("../lib/multicouch"),
+ cmdline = require('commander');
+
+var opts = cmdline
+ .usage('[options] [<prefix>]')
+ .option("-p, --port [number]", "bind server to port", parseInt)
+ .option("-d, --db_dir [path]", "database directory")
+ .option("-c, --couchdb_path [path]", "executable path")
+.parse(process.argv);
+
+if (opts.args.length) opts.prefix = opts.args[0];
+
+var couch_process = new mc(opts);
+couch_process.start();
+
+// HACK: keep process alive until a quit-ly signal is received
+setInterval(function (){}, 60000);
+
+function quit() {
+ couch_process.stop();
+ setTimeout(function () {
+ process.exit();
+ }, 1000);
+}
+// HT: node-supervisor
+['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGQUIT'].forEach(function (s) {
+ process.on(s, quit);
+});
View
7 package.json
@@ -1,6 +1,6 @@
{
"name": "multicouch",
- "version": "0.2.5",
+ "version": "0.2.6",
"description": "Launch multiple CouchDBs from the same installation.",
"main": "lib/multicouch.js",
"scripts": {
@@ -9,5 +9,8 @@
"repository": "git://github.com/hoodiehq/node-multicouch.git",
"author": "Jan Lehnardt",
"license": "Apache 2",
- "readmeFilename": "README.md"
+ "readmeFilename": "README.md",
+ "dependencies": {
+ "commander": "1.x"
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.