mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-16 16:23:25 +00:00
Updated KVM detection, to retry every 10 seconds for 3 minutes if XLIBS are detected but X server is not
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -195,6 +195,7 @@ function monitorinfo()
|
|||||||
|
|
||||||
if(process.platform == 'linux' || process.platform == 'freebsd')
|
if(process.platform == 'linux' || process.platform == 'freebsd')
|
||||||
{
|
{
|
||||||
|
require('events').EventEmitter.call(this, true).createEvent('kvmSupportDetected');
|
||||||
this.MOTIF_FLAGS =
|
this.MOTIF_FLAGS =
|
||||||
{
|
{
|
||||||
MWM_FUNC_ALL : (1 << 0) ,
|
MWM_FUNC_ALL : (1 << 0) ,
|
||||||
@@ -208,12 +209,38 @@ function monitorinfo()
|
|||||||
|
|
||||||
if (this.Location_X11LIB && this.Location_X11TST && this.Location_X11EXT)
|
if (this.Location_X11LIB && this.Location_X11TST && this.Location_X11EXT)
|
||||||
{
|
{
|
||||||
var ch = require('child_process').execFile('/bin/sh', ['sh']);
|
this._xtries = 0;
|
||||||
ch.stderr.on('data', function () { });
|
this._kvmCheck = function _kvmCheck()
|
||||||
ch.stdout.str = ''; ch.stdout.on('data', function (c) { this.str += c.toString(); });
|
{
|
||||||
ch.stdin.write('ps -e | grep X\nexit\n');
|
var ch = require('child_process').execFile('/bin/sh', ['sh']);
|
||||||
ch.waitExit();
|
ch.stderr.on('data', function () { });
|
||||||
Object.defineProperty(this, 'kvm_x11_support', { value: ch.stdout.str.trim() == '' ? false : true });
|
ch.stdout.str = ''; ch.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||||
|
ch.stdin.write('ps -e | grep X\nexit\n');
|
||||||
|
ch.waitExit();
|
||||||
|
|
||||||
|
if (ch.stdout.str.trim() != '')
|
||||||
|
{
|
||||||
|
// X Server found
|
||||||
|
Object.defineProperty(this, 'kvm_x11_serverFound', { value: true });
|
||||||
|
this.emit('kvmSupportDetected', true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this._xtries++ < 18)
|
||||||
|
{
|
||||||
|
this._xtry = setTimeout(function (that) { that._kvmCheck.call(that); }, 10000, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._kvmCheck();
|
||||||
|
Object.defineProperty(this, 'kvm_x11_support', { get: function () { return (this.kvm_x11_serverFound); } });
|
||||||
|
this.on('newListener', function (name, handler)
|
||||||
|
{
|
||||||
|
if(name == 'kvmSupportDetected' && this.kvm_x11_serverFound)
|
||||||
|
{
|
||||||
|
handler.call(this, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user