cleaner
This commit is contained in:
parent
ce8ff2f3e5
commit
597eb0e383
@ -2,7 +2,7 @@ from os import listdir, mkdir
|
|||||||
from os.path import join, exists
|
from os.path import join, exists
|
||||||
from subprocess import call, TimeoutExpired
|
from subprocess import call, TimeoutExpired
|
||||||
|
|
||||||
from SprintLib.queue import notify
|
from SprintLib.queue import notify, send_to_queue
|
||||||
from Main.models import ExtraFile, SolutionFile
|
from Main.models import ExtraFile, SolutionFile
|
||||||
from Main.models.progress import Progress
|
from Main.models.progress import Progress
|
||||||
from Sprint.settings import CONSTS
|
from Sprint.settings import CONSTS
|
||||||
@ -172,13 +172,13 @@ class BaseTester:
|
|||||||
self.solution.result = "TE"
|
self.solution.result = "TE"
|
||||||
raise e
|
raise e
|
||||||
self.solution.save()
|
self.solution.save()
|
||||||
self.call(f"docker rm --force solution_{self.solution.id}")
|
send_to_queue("cleaner", {"type": "container", "name": f"solution_{self.solution.id}"})
|
||||||
self.call(f"docker rm --force solution_{self.solution.id}_checker")
|
send_to_queue("cleaner", {"type": "container", "name": f"solution_{self.solution.id}_checker"})
|
||||||
for file in self.dockerfiles:
|
for file in self.dockerfiles:
|
||||||
add_name = file.filename[11:]
|
add_name = file.filename[11:]
|
||||||
self.call(f"docker rm --force solution_container_{self.solution.id}_{add_name}")
|
send_to_queue("cleaner", {"type": "container", "name": f"solution_container_{self.solution.id}_{add_name}"})
|
||||||
self.call(f"docker image rm solution_image_{self.solution.id}_{add_name}")
|
send_to_queue("cleaner", {"type": "image", "name": f"solution_image_{self.solution.id}_{add_name}"})
|
||||||
self.call(f"docker network rm solution_network_{self.solution.id}")
|
send_to_queue("cleaner", {"type": "network", "name": f"docker network rm solution_network_{self.solution.id}"})
|
||||||
self.solution.user.userinfo.refresh_from_db()
|
self.solution.user.userinfo.refresh_from_db()
|
||||||
notify(
|
notify(
|
||||||
self.solution.user,
|
self.solution.user,
|
||||||
|
11
daemons/management/commands/docker_cleaner.py
Normal file
11
daemons/management/commands/docker_cleaner.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from subprocess import call
|
||||||
|
|
||||||
|
from SprintLib.queue import MessagingSupport
|
||||||
|
|
||||||
|
|
||||||
|
class Command(MessagingSupport):
|
||||||
|
help = "starts docker cleaner"
|
||||||
|
queue_name = "cleaner"
|
||||||
|
|
||||||
|
def process(self, payload: dict):
|
||||||
|
call(f'docker {payload["type"]} rm --force {payload["name"]}', shell=True)
|
Loading…
Reference in New Issue
Block a user