Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECONNREFUSED after 'start' event sent #4

Open
natevw opened this issue Feb 1, 2013 · 1 comment
Open

ECONNREFUSED after 'start' event sent #4

natevw opened this issue Feb 1, 2013 · 1 comment

Comments

@natevw
Copy link
Contributor

natevw commented Feb 1, 2013

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:

  • the start event is emitted synchronously, so it can't be registered later
  • even if I move start to after the event registration, it's still called to early and I get ECONNREFUSED
@ghost ghost assigned janl Feb 3, 2013
@janl
Copy link
Contributor

janl commented Feb 6, 2013

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants