nixos/httpd: provision log directory with tmpfiles instead of mkdir

This commit is contained in:
Aaron Andersen 2020-01-28 19:29:14 -05:00
parent 01ccb67598
commit 0224720562

View File

@ -681,6 +681,15 @@ in
"access_compat" "access_compat"
]; ];
systemd.tmpfiles.rules =
let
svc = config.systemd.services.httpd.serviceConfig;
in
[
"d '${cfg.logDir}' 0700 ${svc.User} ${svc.Group}"
"Z '${cfg.logDir}' - ${svc.User} ${svc.Group}"
];
systemd.services.httpd = systemd.services.httpd =
let let
vhostsACME = filter (hostOpts: hostOpts.enableACME) vhosts; vhostsACME = filter (hostOpts: hostOpts.enableACME) vhosts;
@ -701,8 +710,6 @@ in
preStart = preStart =
'' ''
mkdir -m 0700 -p ${cfg.logDir}
# Get rid of old semaphores. These tend to accumulate across # Get rid of old semaphores. These tend to accumulate across
# server restarts, eventually preventing it from restarting # server restarts, eventually preventing it from restarting
# successfully. # successfully.
@ -715,6 +722,7 @@ in
ExecStart = "@${pkg}/bin/httpd httpd -f ${httpdConf}"; ExecStart = "@${pkg}/bin/httpd httpd -f ${httpdConf}";
ExecStop = "${pkg}/bin/httpd -f ${httpdConf} -k graceful-stop"; ExecStop = "${pkg}/bin/httpd -f ${httpdConf} -k graceful-stop";
ExecReload = "${pkg}/bin/httpd -f ${httpdConf} -k graceful"; ExecReload = "${pkg}/bin/httpd -f ${httpdConf} -k graceful";
User = "root";
Group = cfg.group; Group = cfg.group;
Type = "forking"; Type = "forking";
PIDFile = "${runtimeDir}/httpd.pid"; PIDFile = "${runtimeDir}/httpd.pid";