mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-07-27 07:54:54 +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) {
|
}).fail(function (error) {
|
||||||
|
|
||||||
// Gets the error code for transport errors and XAPI errors.
|
// Gets the error code for transport errors and XAPI errors.
|
||||||
var previous = current;
|
|
||||||
current = error.code || error[0];
|
current = error.code || error[0];
|
||||||
|
|
||||||
// XAPI sommetimes close the connection when the server is
|
// XAPI sommetimes close the connection when the server is
|
||||||
// no longer pool master (`event.next`), so we have to
|
// no longer pool master (`event.next`), so we have to
|
||||||
// retry at least once to know who is the new pool master.
|
// 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
|
// Node.js seems to reuse the broken socket, so we add
|
||||||
// broken socket.
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.host)
|
||||||
|
{
|
||||||
|
console.log('changing host from '+ this.host +' to '+ host);
|
||||||
|
}
|
||||||
|
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.xmlrpc = xmlrpc.createSecureClient({
|
this.xmlrpc = xmlrpc.createSecureClient({
|
||||||
hostname: host,
|
hostname: host,
|
||||||
|
@ -335,6 +335,8 @@ Xo.prototype.start = function (cfg) {
|
|||||||
}).fail(function (error) {
|
}).fail(function (error) {
|
||||||
if ('SESSION_NOT_REGISTERED' === error[0])
|
if ('SESSION_NOT_REGISTERED' === error[0])
|
||||||
{
|
{
|
||||||
|
console.log('registering for events on '+ xapi.host);
|
||||||
|
|
||||||
// We are registering for events here to
|
// We are registering for events here to
|
||||||
// properly handle reconnections.
|
// properly handle reconnections.
|
||||||
return xapi.call('event.register', ['*']).then(loop);
|
return xapi.call('event.register', ['*']).then(loop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user