Permalink
Browse files

basic implementation of CLI utility, just a couple options

  • Loading branch information...
1 parent 8a42690 commit 5be683ee408f37450ad8d060f3766a101c026f4b @natevw natevw committed Feb 6, 2013
Showing with 33 additions and 4 deletions.
  1. +29 −3 bin/multicouch
  2. +4 −1 package.json
View
@@ -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
@@ -9,5 +9,8 @@
"repository": "git://github.com/hoodiehq/node-multicouch.git",
"author": "Jan Lehnardt",
"license": "Apache 2",
- "readmeFilename": "README.md"
+ "readmeFilename": "README.md",
+ "devDependencies": {
+ "commander": "1.x"
+ }
}

0 comments on commit 5be683e

Please sign in to comment.