Open sungshon opened 5 years ago
Running as a service might be overkill for this project..
Hi, i use os-service and sudo-prompt to elevated , it is service wrapper for win and linux, i modified nodePath by execute my .exe, example:
export async function install(_programArgs = []) { try { const programArgs = _programArgs; if (_programArgs.length === 0) { if ('cluster' in argvs) programArgs.push(
--cluster ${Number(argvs.cluster)}); if ('ssl' in argvs) programArgs.push(
--ssl ${Number(argvs.cluster)}`);
}
const root = await isElevated();
if (!root) {
logger.warn('Se requieren permisos de administrador para la instalación');
try {
console.log(await sudo(`${cmd} install ${programArgs.join(' ')}`));
return;
} catch (error) {
logger.error(error);
} finally {
process.exit(0);
}
}
programArgs.push('--service');
const options = {
displayName: 'Virtual Control Software',
programPath: !!process.pkg ? 'run' : undefined,
programArgs,
nodePath: `${process.execPath}`.replace(/(\\)/gi, `\\`),
};
argvs.username &&
Object.assign(options, {
username: argvs.username,
password: argvs.password,
});
logger.info(`${argvs.serviceName}:`);
console.log(options);
service.add(argvs.serviceName, options, error => {
if (error) logger.error(error.toString());
else logger.info('Servicio instalado exitosamente');
process.exit(0);
});
} catch (error) { logger.error(error); } } `
Needs research