From 270d4ae4c0efcf9028cb3ab0fb3d2ef15e038aca Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 18 Jul 2024 02:09:23 +0200 Subject: [PATCH] initial work on the reloader/watcher services for the site this doesn't seem to entirely be working but it reloads? I got an older version on the actual site even though the file did change not sure what's wrong will try to fix this later --- hosts/chmura/jacekpoz.pl.nix | 58 +++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/hosts/chmura/jacekpoz.pl.nix b/hosts/chmura/jacekpoz.pl.nix index 6be4034..67d80fa 100644 --- a/hosts/chmura/jacekpoz.pl.nix +++ b/hosts/chmura/jacekpoz.pl.nix @@ -1,9 +1,15 @@ { inputs, + lib, pkgs, ... }: let + inherit (lib) getExe'; + + systemctl = getExe' pkgs.systemd "systemctl"; + port = 4827; + sitePath = "/srv/web/jacekpoz.pl"; in { services.caddy = { enable = true; @@ -28,22 +34,46 @@ in { group = "site"; }; - systemd.services.pozback = { - description = "The backend for jacekpoz.pl"; - wantedBy = ["default.target"]; + systemd = { + services = { + pozback = { + description = "The backend for jacekpoz.pl"; + after = ["network.target"]; + wantedBy = ["multi-user.target"]; - serviceConfig = { - Type = "simple"; - ExecStart = "${inputs.pozsite.packages.${pkgs.system}.pozback}/bin/back"; - Restart = "on-failure"; - Environment = ''POZ_PORT="${toString port}" POZ_DIR="/srv/web/jacekpoz.pl"''; - User = "site"; - Group = "site"; + serviceConfig = { + Type = "simple"; + ExecStart = "${inputs.pozsite.packages.${pkgs.system}.pozback}/bin/back"; + Restart = "on-failure"; + Environment = ''POZ_PORT="${toString port}" POZ_DIR="${sitePath}"''; + User = "site"; + Group = "site"; + }; + + path = with pkgs; [ + fastfetch + colorized-logs + ]; + }; + + pozback-watcher = { + description = "Restarter for the backend"; + after = ["network.target"]; + wantedBy = ["multi-user.target"]; + + serviceConfig = { + Type = "oneshot"; + ExecStart = "${systemctl} restart pozback.service"; + }; + }; }; + paths.pozback-watcher = { + wantedBy = ["multi-user.target"]; - path = with pkgs; [ - fastfetch - colorized-logs - ]; + pathConfig = { + PathModified = sitePath; + Unit = "pozback-watcher.service"; + }; + }; }; }