mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-20 20:16:26 +02:00
cleanup all runner user processes
This commit is contained in:
parent
3b0f2a0013
commit
72bda367e0
3 changed files with 30 additions and 45 deletions
|
@ -5,6 +5,7 @@ const path = require('path');
|
|||
const config = require('./config');
|
||||
const globals = require('./globals');
|
||||
const fs = require('fs/promises');
|
||||
const ps_list = require('ps-list');
|
||||
|
||||
const job_states = {
|
||||
READY: Symbol('Ready to be primed'),
|
||||
|
@ -183,6 +184,17 @@ class Job {
|
|||
async cleanup() {
|
||||
logger.info(`Cleaning up job uuid=${this.uuid}`);
|
||||
await fs.rm(this.dir, { recursive: true, force: true });
|
||||
|
||||
let processes = await ps_list();
|
||||
processes.filter(proc => proc.uid == this.uid);
|
||||
|
||||
await Promise.all(
|
||||
processes.map(
|
||||
proc => process.kill(proc.pid, 'SIGKILL')
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue