Added error checking at self update npm install

This commit is contained in:
Noah Zalev 2021-04-18 18:11:52 -04:00
parent 0b53e6b753
commit fad0f767ca
1 changed files with 7 additions and 2 deletions

View File

@ -445,11 +445,16 @@ function CreateMeshCentralServer(config, args) {
var npmproxy = ((typeof obj.args.npmproxy == 'string') ? (' --proxy ' + obj.args.npmproxy) : ''); var npmproxy = ((typeof obj.args.npmproxy == 'string') ? (' --proxy ' + obj.args.npmproxy) : '');
var env = Object.assign({}, process.env); // Shallow clone var env = Object.assign({}, process.env); // Shallow clone
if (typeof obj.args.npmproxy == 'string') { env['HTTP_PROXY'] = env['HTTPS_PROXY'] = env['http_proxy'] = env['https_proxy'] = obj.args.npmproxy; } if (typeof obj.args.npmproxy == 'string') { env['HTTP_PROXY'] = env['HTTPS_PROXY'] = env['http_proxy'] = env['https_proxy'] = obj.args.npmproxy; }
var xxprocess = child_process.exec(npmpath + ' install meshcentral' + version + npmproxy, { maxBuffer: Infinity, cwd: obj.parentpath, env: env }, function (error, stdout, stderr) { }); var xxprocess = child_process.exec(npmpath + ' install meshcentral' + version + npmproxy, { maxBuffer: Infinity, cwd: obj.parentpath, env: env }, function (error, stdout, stderr) {
if ((error != null) && (error != '')) { console.log('Update failed: ' + error); }
});
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) { console.log('Update completed...'); setTimeout(function () { obj.launchChildServer(startArgs); }, 1000); }); xxprocess.on('close', function (code) {
if (code == 0) { 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