Attempt to stop containers in App update/uninstall, closes #3

This commit is contained in:
Disassembler 2020-04-26 18:41:42 +02:00
parent cedd257f63
commit bb694671f2
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
3 changed files with 12 additions and 8 deletions

View File

@ -1,7 +1,7 @@
# Contributor: Disassembler <disassembler@dasm.cz> # Contributor: Disassembler <disassembler@dasm.cz>
# Maintainer: Disassembler <disassembler@dasm.cz> # Maintainer: Disassembler <disassembler@dasm.cz>
pkgname=spoc pkgname=spoc
pkgver=0.0.1 pkgver=0.9.2
pkgrel=0 pkgrel=0
pkgdesc="SPOC application, container, and image manager" pkgdesc="SPOC application, container, and image manager"
url="https://spotter.vm/" url="https://spotter.vm/"

View File

@ -85,7 +85,10 @@ def modify(container_name, depends, mounts, env, uid, gid, cmd, cwd, ready, halt
def destroy(container_name): def destroy(container_name):
# Remove container and its directory # Remove container and its directory
Container(container_name, False).destroy() container = Container(container_name, False)
if container.is_running():
container.stop()
container.destroy()
def start(container_name, command): def start(container_name, command):
# Start the container using init values from its definition # Start the container using init values from its definition

View File

@ -108,8 +108,10 @@ class App:
repo_local.register_app(self.name, self.get_definition()) repo_local.register_app(self.name, self.get_definition())
def update(self, observer=None): def update(self, observer=None):
# Remove containers # Stop and remove containers
for container in self.containers.copy(): for container in self.containers.copy():
if container.is_running():
container.stop()
container.destroy() container.destroy()
self.containers.remove(container) self.containers.remove(container)
# Load online definition # Load online definition
@ -130,14 +132,13 @@ class App:
repo_local.register_app(self.name, self.get_definition()) repo_local.register_app(self.name, self.get_definition())
def uninstall(self, observer=None): def uninstall(self, observer=None):
# Make sure the containers are stopped # Stop and remove containers
for container in self.containers: for container in self.containers:
container.stop() if container.is_running():
container.stop()
container.destroy()
# Run uninstall script # Run uninstall script
self.run_script('uninstall') self.run_script('uninstall')
# Remove containers
for container in self.containers:
container.destroy()
# Unregister app and remove scripts # Unregister app and remove scripts
repo_local.unregister_app(self.name) repo_local.unregister_app(self.name)
try: try: