diff --git a/usr/bin/spoc-app b/usr/bin/spoc-app index 7a6db99..14a152f 100755 --- a/usr/bin/spoc-app +++ b/usr/bin/spoc-app @@ -63,11 +63,15 @@ def uninstall(app_name): def start(app_name): # Start all application containers - App(app_name).start() + queue = ActionQueue() + queue.start_app(App(app_name)) + queue.process() def stop(app_name): # Stop all application containers - App(app_name).stop() + queue = ActionQueue() + queue.stop_app(App(app_name)) + queue.process() def status(app_name): # Print status of all application containers diff --git a/usr/lib/python3.8/spoc/app.py b/usr/lib/python3.8/spoc/app.py index ca9d5ab..4df7a76 100644 --- a/usr/lib/python3.8/spoc/app.py +++ b/usr/lib/python3.8/spoc/app.py @@ -133,15 +133,23 @@ class App: except FileNotFoundError: pass - def start(self): + def start(self, observer=None): # Start all application containers + if observer: + observer.units_total = len(self.containers) for container in self.containers: container.start() + if observer: + observer.units_done += 1 - def stop(self): + def stop(self, observer=None): # Stop all application containers + if observer: + observer.units_total = len(self.containers) for container in self.containers: container.stop() + if observer: + observer.units_done += 1 def status(self): # Return status fo all application containers diff --git a/usr/lib/python3.8/spoc/cli.py b/usr/lib/python3.8/spoc/cli.py index a22f765..dab4be6 100644 --- a/usr/lib/python3.8/spoc/cli.py +++ b/usr/lib/python3.8/spoc/cli.py @@ -54,6 +54,12 @@ class ActionQueue: def uninstall_app(self, app): self.queue.append(ActionItem(f'Uninstalling application {app.name}', app.uninstall)) + def start_app(self, app): + self.queue.append(ActionItem(f'Starting application {app.name}', app.start)) + + def stop_app(self, app): + self.queue.append(ActionItem(f'Stopping application {app.name}', app.stop)) + def process(self): index = 0 queue_length = len(self.queue)