Initial working radio controller for OP25

This commit is contained in:
Logan Cusano
2023-05-20 14:31:43 -04:00
parent 0f003f907e
commit c4070cc420
6 changed files with 156 additions and 34 deletions

View File

@@ -8,6 +8,32 @@ const log = new DebugBuilder("client", "executeConsoleCommands");
const execCommand = promisify(exec);
/**
*
* @param {*} process The process to close
* @returns {undefined} Undefined to replace the existing process in the parent
*/
exports.closeProcessWrapper = async (process) => {
log.INFO("Leaving the server");
if (!process) return undefined;
// Try to close the process gracefully
await process.kill(2);
// Wait 25 seconds and see if the process is still open, if it is force it close
await setTimeout(async () => {
if (process) await process.kill(9);
}, 25000)
return undefined;
}
/**
*
* @param {*} consoleCommand
* @returns
*/
exports.executeAsyncConsoleCommand = async function executeAsyncConsoleCommand(consoleCommand) {
// Check to see if the command is a real command
// TODO needs to be improved