Fixed server self-update

This commit is contained in:
Ylian Saint-Hilaire 2019-07-18 13:30:49 -07:00
parent c2844f65d1
commit 89bfce1dc6
2 changed files with 7 additions and 12 deletions

View File

@ -176,21 +176,16 @@ function CreateMeshCentralServer(config, args) {
process.exit(); // User CTRL-C exit. process.exit(); // User CTRL-C exit.
} else if (childProcess.xrestart == 3) { } else if (childProcess.xrestart == 3) {
// Server self-update exit // Server self-update exit
var updateArgs = []; var version = '';
var npmpath = ((typeof obj.args.npmpath == 'string') ? obj.args.npmpath : 'npm'); if (typeof obj.args.selfupdate == 'string') { version = '@' + obj.args.selfupdate; }
if (typeof obj.args.npmproxy == 'string') { updateArgs.push('--proxy', obj.args.npmproxy); }
updateArgs.push('install', 'meshcentral');
if (typeof obj.args.selfupdate == 'string') { updateArgs.push('@' + obj.args.selfupdate); }
var child_process = require('child_process'); var child_process = require('child_process');
var xxprocess = child_process.execFile(npmpath, updateArgs, { maxBuffer: Infinity, cwd: obj.parentpath }, function (error, stdout, stderr) { }); var npmpath = ((typeof obj.args.npmpath == 'string') ? obj.args.npmpath : 'npm');
var npmproxy = ((typeof obj.args.npmproxy == 'string') ? (' --proxy ' + obj.args.npmproxy) : '');
var xxprocess = child_process.exec(npmpath + ' install meshcentral' + version + npmproxy, { maxBuffer: Infinity, cwd: obj.parentpath }, function (error, stdout, stderr) { });
xxprocess.data = ''; xxprocess.data = '';
xxprocess.stdout.on('data', function (data) { xxprocess.data += data; }); xxprocess.stdout.on('data', function (data) { xxprocess.data += data; });
xxprocess.stderr.on('data', function (data) { xxprocess.data += data; }); xxprocess.stderr.on('data', function (data) { xxprocess.data += data; });
xxprocess.on('close', function (code) { xxprocess.on('close', function (code) { console.log('Update completed...'); setTimeout(function () { obj.launchChildServer(startArgs); }, 1000); });
console.log('Update completed...');
setTimeout(function () { obj.launchChildServer(startArgs); }, 1000);
});
} else { } else {
if (error != null) { if (error != null) {
// This is an un-expected restart // This is an un-expected restart

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.3.8-b", "version": "0.3.8-d",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",