mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-04-08 20:55:02 +02:00
Various updates.
This commit is contained in:
parent
c759df855d
commit
e8b1be6568
17
src/xapi.js
17
src/xapi.js
@ -46,18 +46,20 @@ Xapi.prototype.call = function (method) {
|
||||
}).fail(function (error) {
|
||||
|
||||
// Gets the error code for transport errors and XAPI errors.
|
||||
var previous = current;
|
||||
current = error.code || error[0];
|
||||
|
||||
// XAPI sommetimes close the connection when the server is
|
||||
// no longer pool master (`event.next`), so we have to
|
||||
// retry at least once to know who is the new pool master.
|
||||
if (('ECONNRESET' === current) && (previous !== current))
|
||||
if (('ECONNRESET' === current)
|
||||
|| ('ECONNREFUSED' === current))
|
||||
{
|
||||
// @todo Does not work because it seems to reuse the
|
||||
// broken socket.
|
||||
// Node.js seems to reuse the broken socket, so we add
|
||||
// a small delay.
|
||||
|
||||
return Q.delay(2000).then(helper);
|
||||
// @todo Add a limit to avoid trying indefinitely.
|
||||
|
||||
return Q.delay(1000).then(helper);
|
||||
}
|
||||
|
||||
//
|
||||
@ -91,6 +93,11 @@ Xapi.prototype.changeHost = function (host) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.host)
|
||||
{
|
||||
console.log('changing host from '+ this.host +' to '+ host);
|
||||
}
|
||||
|
||||
this.host = host;
|
||||
this.xmlrpc = xmlrpc.createSecureClient({
|
||||
hostname: host,
|
||||
|
@ -335,6 +335,8 @@ Xo.prototype.start = function (cfg) {
|
||||
}).fail(function (error) {
|
||||
if ('SESSION_NOT_REGISTERED' === error[0])
|
||||
{
|
||||
console.log('registering for events on '+ xapi.host);
|
||||
|
||||
// We are registering for events here to
|
||||
// properly handle reconnections.
|
||||
return xapi.call('event.register', ['*']).then(loop);
|
||||
|
Loading…
x
Reference in New Issue
Block a user