hoodiehq-archive / node-multicouch

Launch multiple CouchDBs from the same installation.
30 stars 18 forks source link

ECONNREFUSED after 'start' event sent #4

Open natevw opened 11 years ago

natevw commented 11 years ago

It'd be cool if this could notify only after the spawned CouchDB was ready for connections.

var mc = require('multicouch'),
    f = require('fermata');

var TEST_PORT = 4984;

var my_couch = new mc({port:TEST_PORT, prefix: "/tmp"});
my_couch.start();

my_couch.on('start', function () {
    f.json("http://localhost:"+TEST_PORT)._all_dbs.get(function (e,d) {
        console.log(e,d);
    });
});

The code above doesn't work for two reasons:

janl commented 11 years ago

This is because CouchDB’s startup is async as well, after we launch the cli script, we need to periodically request http://couch_url:port/ until we get a valid response before emitting 'start'.

Should be easy to write, if you fancy :)