mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 04:02:55 +03:00
nixos/phpfpm: deprecate poolConfigs option
This commit is contained in:
parent
8f8d9abca4
commit
0ce8317c46
@ -178,6 +178,9 @@ with lib;
|
|||||||
The starting time can be configured via <literal>services.postgresqlBackup.startAt</literal>.
|
The starting time can be configured via <literal>services.postgresqlBackup.startAt</literal>.
|
||||||
'')
|
'')
|
||||||
|
|
||||||
|
# phpfpm
|
||||||
|
(mkRemovedOptionModule [ "services" "phpfpm" "poolConfigs" ] "Use services.phpfpm.pools instead.")
|
||||||
|
|
||||||
# zabbixServer
|
# zabbixServer
|
||||||
(mkRenamedOptionModule [ "services" "zabbixServer" "dbServer" ] [ "services" "zabbixServer" "database" "host" ])
|
(mkRenamedOptionModule [ "services" "zabbixServer" "dbServer" ] [ "services" "zabbixServer" "database" "host" ])
|
||||||
|
|
||||||
|
@ -119,24 +119,26 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.phpfpm.poolConfigs.roundcube = ''
|
services.phpfpm.pools.roundcube = {
|
||||||
listen = /run/phpfpm/roundcube
|
listen = "/run/phpfpm/roundcube";
|
||||||
listen.owner = nginx
|
extraConfig = ''
|
||||||
listen.group = nginx
|
listen.owner = nginx
|
||||||
listen.mode = 0660
|
listen.group = nginx
|
||||||
user = nginx
|
listen.mode = 0660
|
||||||
pm = dynamic
|
user = nginx
|
||||||
pm.max_children = 75
|
pm = dynamic
|
||||||
pm.start_servers = 2
|
pm.max_children = 75
|
||||||
pm.min_spare_servers = 1
|
pm.start_servers = 2
|
||||||
pm.max_spare_servers = 20
|
pm.min_spare_servers = 1
|
||||||
pm.max_requests = 500
|
pm.max_spare_servers = 20
|
||||||
php_admin_value[error_log] = 'stderr'
|
pm.max_requests = 500
|
||||||
php_admin_flag[log_errors] = on
|
php_admin_value[error_log] = 'stderr'
|
||||||
php_admin_value[post_max_size] = 25M
|
php_admin_flag[log_errors] = on
|
||||||
php_admin_value[upload_max_filesize] = 25M
|
php_admin_value[post_max_size] = 25M
|
||||||
catch_workers_output = yes
|
php_admin_value[upload_max_filesize] = 25M
|
||||||
'';
|
catch_workers_output = yes
|
||||||
|
'';
|
||||||
|
};
|
||||||
systemd.services.phpfpm-roundcube.after = [ "roundcube-setup.service" ];
|
systemd.services.phpfpm-roundcube.after = [ "roundcube-setup.service" ];
|
||||||
|
|
||||||
systemd.services.roundcube-setup = let
|
systemd.services.roundcube-setup = let
|
||||||
|
@ -164,19 +164,21 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.phpfpm.poolConfigs = mkIf (cfg.pool == "${poolName}") {
|
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
||||||
"${poolName}" = ''
|
"${poolName}" = {
|
||||||
listen = "${phpfpmSocketName}"
|
listen = phpfpmSocketName;
|
||||||
listen.owner = nginx
|
extraConfig = ''
|
||||||
listen.group = nginx
|
listen.owner = nginx
|
||||||
listen.mode = 0600
|
listen.group = nginx
|
||||||
user = icingaweb2
|
listen.mode = 0600
|
||||||
pm = dynamic
|
user = icingaweb2
|
||||||
pm.max_children = 75
|
pm = dynamic
|
||||||
pm.start_servers = 2
|
pm.max_children = 75
|
||||||
pm.min_spare_servers = 2
|
pm.start_servers = 2
|
||||||
pm.max_spare_servers = 10
|
pm.min_spare_servers = 2
|
||||||
'';
|
pm.max_spare_servers = 10
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.phpfpm.phpOptions = mkIf (cfg.pool == "${poolName}")
|
services.phpfpm.phpOptions = mkIf (cfg.pool == "${poolName}")
|
||||||
|
@ -225,22 +225,24 @@ in {
|
|||||||
serviceConfig.UMask = "0007";
|
serviceConfig.UMask = "0007";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.phpfpm.poolConfigs = let
|
services.phpfpm.pools = let
|
||||||
# workaround for when both are null and need to generate a string,
|
# workaround for when both are null and need to generate a string,
|
||||||
# which is illegal, but as assertions apparently are being triggered *after* config generation,
|
# which is illegal, but as assertions apparently are being triggered *after* config generation,
|
||||||
# we have to avoid already throwing errors at this previous stage.
|
# we have to avoid already throwing errors at this previous stage.
|
||||||
socketOwner = if (cfg.nginx != null) then config.services.nginx.user
|
socketOwner = if (cfg.nginx != null) then config.services.nginx.user
|
||||||
else if (cfg.webServerUser != null) then cfg.webServerUser else "";
|
else if (cfg.webServerUser != null) then cfg.webServerUser else "";
|
||||||
in {
|
in {
|
||||||
${pool} = ''
|
${pool} = {
|
||||||
listen = "${phpSocket}"
|
listen = phpSocket;
|
||||||
listen.owner = ${socketOwner}
|
extraConfig = ''
|
||||||
listen.group = root
|
listen.owner = ${socketOwner}
|
||||||
listen.mode = 0600
|
listen.group = root
|
||||||
user = ${user}
|
listen.mode = 0600
|
||||||
env[PIWIK_USER_PATH] = ${dataDir}
|
user = ${user}
|
||||||
${cfg.phpfpmProcessManagerConfig}
|
env[PIWIK_USER_PATH] = ${dataDir}
|
||||||
'';
|
${cfg.phpfpmProcessManagerConfig}
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,21 +116,23 @@ in
|
|||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
services.phpfpm.poolConfigs = mkIf (cfg.pool == "${poolName}") {
|
services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
|
||||||
"${poolName}" = ''
|
"${poolName}" = {
|
||||||
listen = "${phpfpmSocketName}";
|
listen = phpfpmSocketName;
|
||||||
listen.owner = nginx
|
extraConfig = ''
|
||||||
listen.group = nginx
|
listen.owner = nginx
|
||||||
listen.mode = 0600
|
listen.group = nginx
|
||||||
user = nginx
|
listen.mode = 0600
|
||||||
pm = dynamic
|
user = nginx
|
||||||
pm.max_children = 75
|
pm = dynamic
|
||||||
pm.start_servers = 10
|
pm.max_children = 75
|
||||||
pm.min_spare_servers = 5
|
pm.start_servers = 10
|
||||||
pm.max_spare_servers = 20
|
pm.min_spare_servers = 5
|
||||||
pm.max_requests = 500
|
pm.max_spare_servers = 20
|
||||||
catch_workers_output = 1
|
pm.max_requests = 500
|
||||||
'';
|
catch_workers_output = 1
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.selfoss-config = {
|
systemd.services.selfoss-config = {
|
||||||
|
@ -4,41 +4,22 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.phpfpm;
|
cfg = config.services.phpfpm;
|
||||||
enabled = cfg.poolConfigs != {} || cfg.pools != {};
|
|
||||||
|
|
||||||
stateDir = "/run/phpfpm";
|
stateDir = "/run/phpfpm";
|
||||||
|
|
||||||
poolConfigs =
|
fpmCfgFile = pool: poolOpts: pkgs.writeText "phpfpm-${pool}.conf" ''
|
||||||
(mapAttrs mapPoolConfig cfg.poolConfigs) //
|
|
||||||
(mapAttrs mapPool cfg.pools);
|
|
||||||
|
|
||||||
mapPoolConfig = n: p: {
|
|
||||||
phpPackage = cfg.phpPackage;
|
|
||||||
phpOptions = cfg.phpOptions;
|
|
||||||
config = p;
|
|
||||||
};
|
|
||||||
|
|
||||||
mapPool = n: p: {
|
|
||||||
phpPackage = p.phpPackage;
|
|
||||||
phpOptions = p.phpOptions;
|
|
||||||
config = ''
|
|
||||||
listen = ${p.listen}
|
|
||||||
${p.extraConfig}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
fpmCfgFile = pool: conf: pkgs.writeText "phpfpm-${pool}.conf" ''
|
|
||||||
[global]
|
[global]
|
||||||
error_log = syslog
|
error_log = syslog
|
||||||
daemonize = no
|
daemonize = no
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
|
|
||||||
[${pool}]
|
[${pool}]
|
||||||
${conf}
|
listen = ${poolOpts.listen}
|
||||||
|
${poolOpts.extraConfig}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
phpIni = pool: pkgs.runCommand "php.ini" {
|
phpIni = poolOpts: pkgs.runCommand "php.ini" {
|
||||||
inherit (pool) phpPackage phpOptions;
|
inherit (poolOpts) phpPackage phpOptions;
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
nixDefaults = ''
|
nixDefaults = ''
|
||||||
sendmail_path = "/run/wrappers/bin/sendmail -t -i"
|
sendmail_path = "/run/wrappers/bin/sendmail -t -i"
|
||||||
@ -84,30 +65,6 @@ in {
|
|||||||
"Options appended to the PHP configuration file <filename>php.ini</filename>.";
|
"Options appended to the PHP configuration file <filename>php.ini</filename>.";
|
||||||
};
|
};
|
||||||
|
|
||||||
poolConfigs = mkOption {
|
|
||||||
default = {};
|
|
||||||
type = types.attrsOf types.lines;
|
|
||||||
example = literalExample ''
|
|
||||||
{ mypool = '''
|
|
||||||
listen = /run/phpfpm/mypool
|
|
||||||
user = nobody
|
|
||||||
pm = dynamic
|
|
||||||
pm.max_children = 75
|
|
||||||
pm.start_servers = 10
|
|
||||||
pm.min_spare_servers = 5
|
|
||||||
pm.max_spare_servers = 20
|
|
||||||
pm.max_requests = 500
|
|
||||||
''';
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
description = ''
|
|
||||||
A mapping between PHP-FPM pool names and their configurations.
|
|
||||||
See the documentation on <literal>php-fpm.conf</literal> for
|
|
||||||
details on configuration directives. If no pools are defined,
|
|
||||||
the phpfpm service is disabled.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
pools = mkOption {
|
pools = mkOption {
|
||||||
type = types.attrsOf (types.submodule (import ./pool-options.nix {
|
type = types.attrsOf (types.submodule (import ./pool-options.nix {
|
||||||
inherit lib config;
|
inherit lib config;
|
||||||
@ -130,14 +87,14 @@ in {
|
|||||||
}
|
}
|
||||||
}'';
|
}'';
|
||||||
description = ''
|
description = ''
|
||||||
PHP-FPM pools. If no pools or poolConfigs are defined, the PHP-FPM
|
PHP-FPM pools. If no pools are defined, the PHP-FPM
|
||||||
service is disabled.
|
service is disabled.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf enabled {
|
config = mkIf (cfg.pools != {}) {
|
||||||
|
|
||||||
systemd.slices.phpfpm = {
|
systemd.slices.phpfpm = {
|
||||||
description = "PHP FastCGI Process manager pools slice";
|
description = "PHP FastCGI Process manager pools slice";
|
||||||
@ -148,7 +105,7 @@ in {
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = flip mapAttrs' poolConfigs (pool: poolConfig:
|
systemd.services = mapAttrs' (pool: poolOpts:
|
||||||
nameValuePair "phpfpm-${pool}" {
|
nameValuePair "phpfpm-${pool}" {
|
||||||
description = "PHP FastCGI Process Manager service for pool ${pool}";
|
description = "PHP FastCGI Process Manager service for pool ${pool}";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
@ -158,8 +115,8 @@ in {
|
|||||||
mkdir -p ${stateDir}
|
mkdir -p ${stateDir}
|
||||||
'';
|
'';
|
||||||
serviceConfig = let
|
serviceConfig = let
|
||||||
cfgFile = fpmCfgFile pool poolConfig.config;
|
cfgFile = fpmCfgFile pool poolOpts;
|
||||||
iniFile = phpIni poolConfig;
|
iniFile = phpIni poolOpts;
|
||||||
in {
|
in {
|
||||||
Slice = "phpfpm.slice";
|
Slice = "phpfpm.slice";
|
||||||
PrivateDevices = true;
|
PrivateDevices = true;
|
||||||
@ -168,10 +125,10 @@ in {
|
|||||||
# XXX: We need AF_NETLINK to make the sendmail SUID binary from postfix work
|
# XXX: We need AF_NETLINK to make the sendmail SUID binary from postfix work
|
||||||
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK";
|
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK";
|
||||||
Type = "notify";
|
Type = "notify";
|
||||||
ExecStart = "${poolConfig.phpPackage}/bin/php-fpm -y ${cfgFile} -c ${iniFile}";
|
ExecStart = "${poolOpts.phpPackage}/bin/php-fpm -y ${cfgFile} -c ${iniFile}";
|
||||||
ExecReload = "${pkgs.coreutils}/bin/kill -USR2 $MAINPID";
|
ExecReload = "${pkgs.coreutils}/bin/kill -USR2 $MAINPID";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
) cfg.pools;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user