Merge remote-tracking branch 'origin/master'

This commit is contained in:
prance 2022-01-30 22:29:22 +01:00
commit 7eecff0b54
2 changed files with 20 additions and 0 deletions

View File

@ -27,3 +27,11 @@ class DockerManager:
container = self.client.containers.get(container_id) container = self.client.containers.get(container_id)
container.stop() container.stop()
container.remove() container.remove()
def remove_volume(self, volume_id):
volume = self.client.volumes.get(volume_id)
if volume is not None:
volume.remove(force=True)

View File

@ -75,3 +75,15 @@ def close_session(sender, instance, **kwargs):
except Session.DoesNotExist: except Session.DoesNotExist:
pass pass
NGINXConfigurator.refresh_config(get_sessions_data()) NGINXConfigurator.refresh_config(get_sessions_data())
@receiver(pre_delete, sender=Profile)
def clean_up_volume(sender, instance, **kwargs):
try:
volume_id = instance.volume
docker_manager = DockerManager()
docker_manager.remove_volume(volume_id)
except :
pass