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')
|
||||
{
|
||||
require('events').EventEmitter.call(this, true).createEvent('kvmSupportDetected');
|
||||
this.MOTIF_FLAGS =
|
||||
{
|
||||
MWM_FUNC_ALL : (1 << 0) ,
|
||||
@@ -207,13 +208,39 @@ function monitorinfo()
|
||||
|
||||
|
||||
if (this.Location_X11LIB && this.Location_X11TST && this.Location_X11EXT)
|
||||
{
|
||||
this._xtries = 0;
|
||||
this._kvmCheck = function _kvmCheck()
|
||||
{
|
||||
var ch = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
ch.stderr.on('data', function () { });
|
||||
ch.stdout.str = ''; ch.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
ch.stdin.write('ps -e | grep X\nexit\n');
|
||||
ch.waitExit();
|
||||
Object.defineProperty(this, 'kvm_x11_support', { value: ch.stdout.str.trim() == '' ? false : true });
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user