aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-22 22:48:13 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-22 22:48:13 +0200
commit3202103432740456167424a317c9d40508497a02 (patch)
tree22b99505ccc499e04ab38a06ece0b7cf5a51ac4c /modules
parent830b619fa6ed6b5f2acc6f2eb74e0be98c99710e (diff)
downloadNix-3202103432740456167424a317c9d40508497a02.tar.gz
Nix-3202103432740456167424a317c9d40508497a02.tar.zst
Nix-3202103432740456167424a317c9d40508497a02.zip
Reload httpd service instead of restarting it
Diffstat (limited to 'modules')
-rw-r--r--modules/private/websites/telio_tortay/production.nix4
-rw-r--r--modules/websites/default.nix40
2 files changed, 43 insertions, 1 deletions
diff --git a/modules/private/websites/telio_tortay/production.nix b/modules/private/websites/telio_tortay/production.nix
index 130f4db..cdc61fa 100644
--- a/modules/private/websites/telio_tortay/production.nix
+++ b/modules/private/websites/telio_tortay/production.nix
@@ -60,6 +60,10 @@ in {
60 SetHandler "proxy:unix:${config.services.phpfpm.pools.telio_tortay.socket}|fcgi://localhost" 60 SetHandler "proxy:unix:${config.services.phpfpm.pools.telio_tortay.socket}|fcgi://localhost"
61 </FilesMatch> 61 </FilesMatch>
62 62
63 <Location /xmlrpc.php>
64 AllowOverride None
65 Require all denied
66 </Location>
63 <Directory ${varDir}/logs> 67 <Directory ${varDir}/logs>
64 AllowOverride None 68 AllowOverride None
65 Require all denied 69 Require all denied
diff --git a/modules/websites/default.nix b/modules/websites/default.nix
index d5a0f63..837d838 100644
--- a/modules/websites/default.nix
+++ b/modules/websites/default.nix
@@ -1,4 +1,4 @@
1{ lib, config, ... }: with lib; 1{ lib, config, pkgs, ... }: with lib;
2let 2let
3 cfg = config.services.websites; 3 cfg = config.services.websites;
4in 4in
@@ -274,4 +274,42 @@ in
274 (name: path: "ln -s ${path} $out/${cfg.webappDirsName}/${name}") cfg.webappDirs) 274 (name: path: "ln -s ${path} $out/${cfg.webappDirsName}/${name}") cfg.webappDirs)
275 } 275 }
276 ''; 276 '';
277
278 config.systemd.services = let
279 package = httpdName: config.services.httpd.${httpdName}.package.out;
280 cfgFile = httpdName: config.services.httpd.${httpdName}.configFile;
281 serviceChange = attrsets.mapAttrs' (name: icfg:
282 attrsets.nameValuePair
283 "httpd${icfg.httpdName}" {
284 stopIfChanged = false;
285 serviceConfig.ExecStart =
286 lib.mkForce "@${package icfg.httpdName}/bin/httpd httpd -f /etc/httpd/httpd_${icfg.httpdName}.conf";
287 serviceConfig.ExecStop =
288 lib.mkForce "${package icfg.httpdName}/bin/httpd -f /etc/httpd/httpd_${icfg.httpdName}.conf -k graceful-stop";
289 serviceConfig.ExecReload =
290 lib.mkForce "${package icfg.httpdName}/bin/httpd -f /etc/httpd/httpd_${icfg.httpdName}.conf -k graceful";
291 }
292 ) cfg.env;
293 serviceReload = attrsets.mapAttrs' (name: icfg:
294 attrsets.nameValuePair
295 "httpd${icfg.httpdName}-config-reload" {
296 wants = [ "httpd${icfg.httpdName}.service" ];
297 wantedBy = [ "multi-user.target" ];
298 restartTriggers = [ (cfgFile icfg.httpdName) ];
299 # commented, because can cause extra delays during activate for this config:
300 # services.nginx.virtualHosts."_".locations."/".proxyPass = "http://blabla:3000";
301 # stopIfChanged = false;
302 serviceConfig.Type = "oneshot";
303 serviceConfig.TimeoutSec = 60;
304 script = ''
305 if ${pkgs.systemd}/bin/systemctl -q is-active httpd${icfg.httpdName}.service ; then
306 ${package icfg.httpdName}/bin/httpd -f /etc/httpd/httpd_${icfg.httpdName}.conf -t && \
307 ${pkgs.systemd}/bin/systemctl reload httpd${icfg.httpdName}.service
308 fi
309 '';
310 serviceConfig.RemainAfterExit = true;
311 }
312 ) cfg.env;
313 in
314 serviceChange // serviceReload;
277} 315}