diff --git a/hrms/hooks.py b/hrms/hooks.py index bd61463d80..0de56e5833 100644 --- a/hrms/hooks.py +++ b/hrms/hooks.py @@ -84,7 +84,7 @@ # Installation # ------------ -# before_install = "hrms.install.before_install" +before_install = "hrms.install.before_install" after_install = "hrms.install.after_install" after_migrate = "hrms.setup.update_select_perm_after_install" diff --git a/hrms/install.py b/hrms/install.py index dacb20e532..77b121d7c1 100644 --- a/hrms/install.py +++ b/hrms/install.py @@ -3,6 +3,22 @@ from hrms.setup import after_install as setup +def before_install(): + from frappe.utils.connections import check_connection + + service_status = check_connection(redis_services=["redis_cache"]) + are_services_running = all(service_status.values()) + + if not are_services_running: + for service in service_status: + if not service_status.get(service, True): + click.secho(f"Service {service} is not running.", fg="red") + + click.secho("Please ensure that the server is running before installing HRMS.", fg="red") + click.secho("See: https://github.com/frappe/hrms/issues/369#issuecomment-1463632514", fg="red") + raise click.Abort() + + def after_install(): try: print("Setting up Frappe HR...")