1
0
Fork 0
mirror of https://github.com/engineer-man/piston.git synced 2025-05-07 04:16:26 +02:00

file persistance fix

This commit is contained in:
Thomas Hobson 2021-04-28 16:03:35 +12:00
parent a6bc24e22e
commit 3bd73d07a9
No known key found for this signature in database
GPG key ID: 9F1FD9D87950DB6F
3 changed files with 59 additions and 6 deletions

View file

@ -16,5 +16,11 @@ module.exports = {
},
version: require('../package.json').version,
platform,
pkg_installed_file: '.ppman-installed' //Used as indication for if a package was installed
pkg_installed_file: '.ppman-installed', //Used as indication for if a package was installed
clean_directories: [
"/dev/shm",
"/run/lock",
"/tmp",
"/var/tmp"
]
};

View file

@ -183,12 +183,10 @@ class Job {
};
}
async cleanup() {
logger.info(`Cleaning up job uuid=${this.uuid}`);
await fs.rm(this.dir, { recursive: true, force: true });
async cleanup_processes(){
let processes = [1];
while(processes.length > 0){
processes = await ps_list();
processes = processes.filter(proc => proc.uid == this.uid);
@ -212,8 +210,32 @@ class Job {
wait_pid(proc.pid);
}
}
}
async cleanup_filesystem(){
/*
for (const clean_path of globals.clean_directories) {
const contents = await fs.readdir(clean_path);
for (const file of contents) {
const file_path = path.join(clean_path, file);
const stat = await fs.stat(file_path);
if(stat.uid == this.uid)
await fs.rm(file_path, { recursive: true, force: true });
}
}*/
await fs.rm(this.dir, { recursive: true, force: true });
}
async cleanup() {
logger.info(`Cleaning up job uuid=${this.uuid}`);
await Promise.all([
this.cleanup_processes(),
this.cleanup_filesystem()
]);
}
}