From cacdf1f5b9dbed6cf3da001bac0f9ea29b012ead Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 17 Apr 2024 02:24:45 +0100 Subject: [PATCH] add restart command --- src/command/commandManager.py | 2 ++ src/command/impl/addCommand.py | 4 ++-- src/command/impl/listCommand.py | 2 +- src/command/impl/removeCommand.py | 2 +- src/command/impl/restartCommand.py | 10 ++++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/command/impl/restartCommand.py diff --git a/src/command/commandManager.py b/src/command/commandManager.py index 74e2e48..95a28a1 100644 --- a/src/command/commandManager.py +++ b/src/command/commandManager.py @@ -1,6 +1,7 @@ from command.impl.addCommand import AddCommand from command.impl.listCommand import ListCommand from command.impl.removeCommand import RemoveCommand +from command.impl.restartCommand import RestartCommand class CommandManager: @@ -10,6 +11,7 @@ class CommandManager: self.addCommand(AddCommand()) self.addCommand(RemoveCommand()) self.addCommand(ListCommand()) + self.addCommand(RestartCommand()) pass def addCommand(self, command): diff --git a/src/command/impl/addCommand.py b/src/command/impl/addCommand.py index a00543d..cad9d92 100644 --- a/src/command/impl/addCommand.py +++ b/src/command/impl/addCommand.py @@ -6,7 +6,7 @@ class AddCommand(Command): def __init__(self): super().__init__("add", "Add a domain", "add ") - def execute(self, traefikConfig:TraefikConfig, args): + def execute(self, traefikConfig: TraefikConfig, args): if len(args) < 3: self.printUsage() return @@ -31,6 +31,6 @@ class AddCommand(Command): traefikConfig.save() - restartTraefik() + # restartTraefik() print(f"Access your service at http://{domain}") \ No newline at end of file diff --git a/src/command/impl/listCommand.py b/src/command/impl/listCommand.py index 8959385..1228c62 100644 --- a/src/command/impl/listCommand.py +++ b/src/command/impl/listCommand.py @@ -6,7 +6,7 @@ class ListCommand(Command): def __init__(self): super().__init__("list", "List all services", "list") - def execute(self, traefikConfig:TraefikConfig, args): + def execute(self, traefikConfig: TraefikConfig, args): print("Listing all services:") domains = traefikConfig.getAll() diff --git a/src/command/impl/removeCommand.py b/src/command/impl/removeCommand.py index 6f9c135..4a71fc6 100644 --- a/src/command/impl/removeCommand.py +++ b/src/command/impl/removeCommand.py @@ -7,7 +7,7 @@ class RemoveCommand(Command): def __init__(self): super().__init__("remove", "Remove a domain", "remove ") - def execute(self, traefikConfig:TraefikConfig, args): + def execute(self, traefikConfig: TraefikConfig, args): if len(args) < 0: self.printUsage() return diff --git a/src/command/impl/restartCommand.py b/src/command/impl/restartCommand.py new file mode 100644 index 0000000..0112e7b --- /dev/null +++ b/src/command/impl/restartCommand.py @@ -0,0 +1,10 @@ +from command.command import Command +from traefik.traefikConfig import TraefikConfig +from utils.dockerUtils import restartTraefik + +class RestartCommand(Command): + def __init__(self): + super().__init__("restart", "Restart traefik", "") + + def execute(self, traefikConfig: TraefikConfig, args): + restartTraefik() \ No newline at end of file