Skip to content

Commit

Permalink
phpfpm service: add target and slice
Browse files Browse the repository at this point in the history
  • Loading branch information
fpletz committed Feb 27, 2017
1 parent e3d58da commit ec4ead0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions nixos/modules/services/web-servers/phpfpm/default.nix
Expand Up @@ -4,6 +4,7 @@ with lib;

let
cfg = config.services.phpfpm;
enabled = cfg.poolConfigs != {} || cfg.pools != {};

stateDir = "/run/phpfpm";

Expand Down Expand Up @@ -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:
nameValuePair "phpfpm-${pool}" {
description = "PHP FastCGI Process Manager for pool ${pool}";
description = "PHP FastCGI Process Manager service for pool ${pool}";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
wantedBy = [ "phpfpm.target" ];
partOf = [ "phpfpm.target" ];
preStart = ''
mkdir -p ${stateDir}
'';
serviceConfig = let
cfgFile = fpmCfgFile pool poolConfig;
in {
Slice = "phpfpm.slice";
PrivateTmp = true;
PrivateDevices = true;
ProtectSystem = "full";
Expand Down

0 comments on commit ec4ead0

Please sign in to comment.