diff --git a/deploy/panel_installer/engine.py b/deploy/panel_installer/engine.py index 4211370..7932484 100644 --- a/deploy/panel_installer/engine.py +++ b/deploy/panel_installer/engine.py @@ -34,6 +34,7 @@ PANEL_UNITS = ( "coulobre-worker.service", "coulobre-beat.service", ) +HEALTH_TIMER = "coulobre-health.timer" BASE_PACKAGES = ( "apache2", "mariadb-server", @@ -547,6 +548,20 @@ class Installer: ) def environment(self): + services = [ + "panel", + "worker", + "scheduler", + "apache", + "mariadb", + "rabbitmq", + ] + if self.php: + services.append("php-fpm") + if self.plan.dns.mode == "local": + services.append("bind9") + if self.plan.mail.mode == "local": + services.extend(("postfix", "dovecot", "rspamd", "redis")) options = { "DJANGO_SETTINGS_MODULE": "coulobre.settings", "COULOBRE_ALLOWED_HOSTS": self.plan.hostname, @@ -564,6 +579,9 @@ class Installer: f"amqp://coulobre:{self.state['broker_password']}@127.0.0.1:5672/coulobre" ), "COULOBRE_LOCAL_DATABASE_PROVISIONING": "1", + "COULOBRE_SERVICE_HEALTH": json.dumps( + {"panel": {"local": services}}, separators=(",", ":") + ), } if self.php: options["COULOBRE_LOCAL_WEB_ACTIVATION"] = "1" @@ -829,13 +847,19 @@ class Installer: self.prepare_panel() self.progress("Validating Apache and starting the panel services.") self.apache() - for unit in PANEL_UNITS: + identity("coulobre-health") + for unit in ( + *PANEL_UNITS, + "coulobre-health.service", + HEALTH_TIMER, + ): install_unit(unit) systemctl("daemon-reload") systemctl( "enable", "--now", *PANEL_UNITS, *workers, "apache2.service" ) systemctl("reload", "apache2.service") + systemctl("enable", "--now", HEALTH_TIMER) self.verify_panel() if self.plan.mail.mode == "local": with self.step("Checking Postfix for outgoing panel email"): diff --git a/docs/deployment.md b/docs/deployment.md index f4e4a3b..758f2b8 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -2470,8 +2470,10 @@ states. Use the corresponding service tests to check mail delivery, DNS answers, or website responses. The collector and dashboard both need the panel database to record and display observations. -Set `COULOBRE_SERVICE_HEALTH` in `/etc/coulobre/panel.env`. This example checks -local panel services and two records for remote mail and DNS services. +The installer configures the collector for the services it installs on the +panel host. To enable a collector on an existing host or change the services +it monitors, set `COULOBRE_SERVICE_HEALTH` in `/etc/coulobre/panel.env`. +This example includes separate mail and DNS nodes. ```ini COULOBRE_SERVICE_HEALTH='{"panel-01":{"local":["panel","worker","scheduler","apache","php-fpm","mariadb","rabbitmq"]},"mail-01":{"ssh":["postfix","dovecot"]},"dns-01":{"ssh":["bind9"]}}' @@ -2482,7 +2484,8 @@ starting with a letter. Keep the IDs stable for the same hosts. List one `local` node per panel installation and use `ssh` for each additional host. Use `php-fpm` under `local` to monitor the installed stable PHP-FPM services. The check reports a problem when any of those services is unavailable. -Use `bind9`, `postfix`, `dovecot`, `spamd`, and `spamass-milter` under +Use `bind9`, `postfix`, `dovecot`, `rspamd`, `redis`, `spamd`, and +`spamass-milter` under `local` for co-located services or under `ssh` for separate nodes. Only list the spam filter units where filtering is configured. Update the Coulobre package on a remote node before adding its filter units. The diff --git a/src/coulobre/hosting/installation_views.py b/src/coulobre/hosting/installation_views.py new file mode 100644 index 0000000..8c437e1 --- /dev/null +++ b/src/coulobre/hosting/installation_views.py @@ -0,0 +1,60 @@ +from importlib.metadata import PackageNotFoundError, version + +from django.conf import settings +from django.contrib.auth.mixins import PermissionRequiredMixin +from django.utils.decorators import method_decorator +from django.views.decorators.cache import never_cache +from django.views.generic import TemplateView + +from .access import OperatorOnlyMixin + + +@method_decorator(never_cache, name="dispatch") +class InstallationView( + OperatorOnlyMixin, PermissionRequiredMixin, TemplateView +): + permission_required = "hosting.view_servicehealth" + template_name = "hosting/installation.html" + + def get_context_data(self, **kwargs): + try: + installed_version = version("coulobre-panel") + except PackageNotFoundError: + installed_version = "Unavailable" + + features = ( + ("Local website provisioning", settings.LOCAL_WEB_ACTIVATION), + ("Managed website certificates", settings.LOCAL_WEB_HTTPS), + ("Website file manager", settings.WEB_FILE_MANAGER), + ("Website scheduled tasks", settings.WEBSITE_JOBS), + ("Local DNS publishing", settings.LOCAL_DNS_PUBLISHING), + ( + "Default managed DNS zones for new accounts", + settings.LOCAL_DNS_PUBLISHING + and settings.HOSTING_NAMESERVERS + and settings.HOSTING_PUBLIC_ADDRESSES, + ), + ( + "Local mailbox provisioning", + settings.LOCAL_MAILBOX_PROVISIONING, + ), + ("Managed mail DNS records", settings.MANAGE_MAIL_DNS), + ( + "Local database provisioning", + settings.LOCAL_DATABASE_PROVISIONING, + ), + ("Local account backups", settings.LOCAL_ACCOUNT_BACKUPS), + ( + "Off-site backup destinations", + settings.OFFSITE_BACKUP_DESTINATIONS, + ), + ("phpMyAdmin sign-in", settings.PHPMYADMIN_URL), + ("Roundcube sign-in", settings.ROUNDCUBE_URL), + ) + return super().get_context_data( + installed_version=installed_version, + features=[ + (name, bool(configured)) for name, configured in features + ], + **kwargs, + ) diff --git a/src/coulobre/hosting/static/hosting/field-help.js b/src/coulobre/hosting/static/hosting/field-help.js new file mode 100644 index 0000000..b031697 --- /dev/null +++ b/src/coulobre/hosting/static/hosting/field-help.js @@ -0,0 +1,50 @@ +let activeHelp; +let pinned = false; + +function closeHelp() { + if (activeHelp) activeHelp.open = false; + activeHelp = undefined; + pinned = false; +} + +function showHelp(help) { + if (activeHelp === help) return; + closeHelp(); + help.open = true; + activeHelp = help; +} + +for (const help of document.querySelectorAll("[data-field-help]")) { + const summary = help.querySelector("summary"); + help.addEventListener("pointerenter", (event) => { + if (event.pointerType === "mouse" && !pinned) showHelp(help); + }); + help.addEventListener("pointerleave", () => { + if (activeHelp === help && !pinned && !summary.matches(":focus-visible")) { + closeHelp(); + } + }); + summary.addEventListener("focus", () => { + if (summary.matches(":focus-visible")) showHelp(help); + }); + summary.addEventListener("blur", () => { + if (activeHelp === help) closeHelp(); + }); + summary.addEventListener("click", (event) => { + event.preventDefault(); + if (activeHelp === help && pinned) { + closeHelp(); + } else { + showHelp(help); + pinned = true; + } + }); +} + +document.addEventListener("pointerdown", (event) => { + if (activeHelp && !activeHelp.contains(event.target)) closeHelp(); +}); + +document.addEventListener("keydown", (event) => { + if (event.key === "Escape" && activeHelp) closeHelp(); +}); diff --git a/src/coulobre/hosting/static/hosting/panel.css b/src/coulobre/hosting/static/hosting/panel.css index 87ecf81..3d5eab3 100644 --- a/src/coulobre/hosting/static/hosting/panel.css +++ b/src/coulobre/hosting/static/hosting/panel.css @@ -273,6 +273,14 @@ button, input, select, textarea { linear-gradient(currentColor, currentColor) 75% bottom / 1px 55% no-repeat; } +.nav-icon-information { + display: grid; + place-content: center; + border-radius: 50%; + font-size: 0.7rem; + font-weight: 700; +} + .nav-icon-customers { position: relative; height: 0.46rem; @@ -720,14 +728,54 @@ dd { accent-color: var(--accent); } -.field-help { - padding: 0.65rem 0.75rem; - border: 1px solid var(--line); - border-radius: var(--radius); +.plan-field-heading { + position: relative; + display: flex; + align-items: center; + gap: 0.35rem; + margin-bottom: 0.35rem; } -.field-help dt { - margin-block-start: 0.55rem; +.plan-field-heading label { + margin-bottom: 0; +} + +.field-help summary { + display: grid; + width: 1.5rem; + height: 1.5rem; + place-items: center; + border: 1px solid var(--control-line); + border-radius: 50%; + color: var(--accent); + font-size: 0.8rem; + font-weight: 700; + list-style: none; + cursor: pointer; +} + +.field-help summary::-webkit-details-marker { + display: none; +} + +.field-help summary:hover, .field-help[open] summary { + background: var(--control-hover); +} + +.field-help p { + position: absolute; + z-index: 1; + inset-block-start: 100%; + inset-inline-start: 0; + box-sizing: border-box; + width: min(100%, 25rem); + margin: 0; + padding: 0.6rem 0.75rem; + border: 1px solid var(--control-line); + border-radius: 0.5rem; + background: var(--surface); + box-shadow: 0 4px 12px var(--surface-shadow); + font-size: 0.88rem; } .reseller-editor fieldset { diff --git a/src/coulobre/hosting/templates/hosting/base.html b/src/coulobre/hosting/templates/hosting/base.html index 57a9644..31170d0 100644 --- a/src/coulobre/hosting/templates/hosting/base.html +++ b/src/coulobre/hosting/templates/hosting/base.html @@ -52,8 +52,8 @@ {% endif %} {% if group_customer_navigation %}{% endif %} - {% if is_operator and perms.hosting.view_webprovisioningplan and perms.hosting.view_servicehealth %} - {% endif %} {% endwith %}
{% empty %} -No services are configured for health checks.
Set COULOBRE_SERVICE_HEALTH in /etc/coulobre/panel.env and enable coulobre-health.timer to collect service observations.