30 lines
979 B
Python
30 lines
979 B
Python
# cli/service.py
|
|
from services.odoo.service import OdooServiceManager
|
|
import lib.color_log as color_log
|
|
|
|
|
|
def setup_cli(subparsers):
|
|
service_parser = subparsers.add_parser("service", help="Manage instance service")
|
|
service_parser.add_argument(
|
|
"action", choices=["start", "stop", "restart"], help="Service action"
|
|
)
|
|
service_parser.add_argument("instance", type=str, help="Instance Name")
|
|
service_parser.set_defaults(func=service)
|
|
return service_parser
|
|
|
|
|
|
def service(args):
|
|
service = OdooServiceManager(config_path="utility/config/settings.yaml")
|
|
match args.action:
|
|
case "start":
|
|
service.start_service(args.instance)
|
|
case "stop":
|
|
service.stop_service(args.instance)
|
|
case "restart":
|
|
service.restart_service(args.instance)
|
|
case _:
|
|
color_log.Show(
|
|
"FAILED",
|
|
f"Invalid action '{args.action}' for service management.",
|
|
)
|