phpfpm service: add target and slice

This commit is contained in:
Franz Pletz 2017-02-28 00:00:57 +01:00
parent e3d58dae7f
commit ec4ead0bfe
No known key found for this signature in database
GPG key ID: 846FDED7792617B4

View file

@ -4,6 +4,7 @@ with lib;
let let
cfg = config.services.phpfpm; cfg = config.services.phpfpm;
enabled = cfg.poolConfigs != {} || cfg.pools != {};
stateDir = "/run/phpfpm"; stateDir = "/run/phpfpm";
@ -119,18 +120,30 @@ in {
}; };
}; };
config = { config = mkIf enabled {
systemd.slices.phpfpm = {
description = "PHP FastCGI Process manager pools slice";
};
systemd.targets.phpfpm = {
description = "PHP FastCGI Process manager pools target";
wantedBy = [ "multi-user.target" ];
};
systemd.services = flip mapAttrs' poolConfigs (pool: poolConfig: systemd.services = flip mapAttrs' poolConfigs (pool: poolConfig:
nameValuePair "phpfpm-${pool}" { nameValuePair "phpfpm-${pool}" {
description = "PHP FastCGI Process Manager for pool ${pool}"; description = "PHP FastCGI Process Manager service for pool ${pool}";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "phpfpm.target" ];
partOf = [ "phpfpm.target" ];
preStart = '' preStart = ''
mkdir -p ${stateDir} mkdir -p ${stateDir}
''; '';
serviceConfig = let serviceConfig = let
cfgFile = fpmCfgFile pool poolConfig; cfgFile = fpmCfgFile pool poolConfig;
in { in {
Slice = "phpfpm.slice";
PrivateTmp = true; PrivateTmp = true;
PrivateDevices = true; PrivateDevices = true;
ProtectSystem = "full"; ProtectSystem = "full";