[Application configuration support] [Fix component unmount leak]

This commit is contained in:
Scott E. Graves
2018-09-30 11:00:23 -05:00
parent f11ddb6d75
commit 9968116242
17 changed files with 880 additions and 164 deletions

View File

@@ -195,6 +195,85 @@ module.exports.executeMount = (directory, version, storageType, location, exitCa
});
};
module.exports.getConfig = (directory, version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
shell: false,
windowsHide: true,
};
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
const args = [];
args.push('-dc');
if (storageType.toLowerCase() === 'hyperspace') {
args.push('-hs');
}
const process = new spawn(command, args, processOptions);
let result = '';
process.on('error', (err) => {
reject(err);
});
process.stdout.on('data', (d)=> {
result += d;
});
process.on('exit', () => {
const lines = result
.replace(/\r\n/g, '\n')
.split('\n');
const code = parseInt(lines[0], 10);
if (code === 0) {
lines.shift();
resolve({
Code: code,
Data: JSON.parse(lines.join('\n')),
});
} else {
resolve(code);
}
});
process.unref();
});
};
module.exports.getConfigTemplate = (directory, version, storageType) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
shell: false,
windowsHide: true,
};
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
const args = [];
args.push('-gt');
if (storageType.toLowerCase() === 'hyperspace') {
args.push('-hs');
}
const process = new spawn(command, args, processOptions);
let result = '';
process.on('error', (err) => {
reject(err);
});
process.stdout.on('data', (d)=> {
result += d;
});
process.on('exit', () => {
resolve(JSON.parse(result));
});
process.unref();
});
};
module.exports.getMissingDependencies = dependencies => {
return new Promise((resolve, reject) => {
if (!dependencies || (dependencies.length === 0)) {
@@ -323,6 +402,37 @@ module.exports.resolvePath = str => {
}
};
module.exports.setConfigValue = (name, value, directory, storageType, version) => {
return new Promise((resolve, reject) => {
const processOptions = {
detached: true,
shell: false,
windowsHide: true,
};
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
const args = [];
args.push('-set');
args.push(name);
args.push(value);
if (storageType.toLowerCase() === 'hyperspace') {
args.push('-hs');
}
const process = new spawn(command, args, processOptions);
process.on('error', (err) => {
reject(err);
});
process.on('exit', () => {
resolve();
});
process.unref();
});
};
module.exports.stopProcessByPID = pid => {
return new Promise((resolve, reject) => {
const processOptions = {