import { Process } from '@empathize/framework';
// SIGTERM (-15)
Process.kill(1293);
// SIGKILL (-9)
Process.kill(1293, true);
Object
process.finish(callback)
Specify callback that will be called when the process will be closed
import { Process } from '@empathize/framework';
Process.run('some_command').then((process) => {
process.finish((process) => {
console.log(`Process with id ${process.id} was closed`);
});
});
process.output(callback)
Specify callback that will be called when the process will write some output
import { Process } from '@empathize/framework';
Process.run('some_command').then((process) => {
process.output((output, process) => {
console.log(output);
});
});
process.kill(forced)
import { Process } from '@empathize/framework';
Process.run('some_command').then((process) => {
// Kill this process after 5 seconds with SIGTERM (-15)
setTimeout(() => {
process.kill();
}, 5000);
});
process.running()
import { Process } from '@empathize/framework';
Process.run('some_command').then((process) => {
setInterval(async () => {
const running = await process.running();
if (!running)
console.log('Hey! This process was stopped!');
}, 3000);
});