nixos/pgbouncer: only depend on postgresql.service when enabled and use notify

See also the upstream service file: e6ce619785/etc/pgbouncer.service
This commit is contained in:
Sophie Tauchert 2024-02-02 19:35:01 +01:00
parent b3f483a5c2
commit b89cd583ae
No known key found for this signature in database
GPG Key ID: 52701DE5F5F51125
2 changed files with 8 additions and 11 deletions

View File

@ -162,6 +162,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
`wants`), because the dependency that `multi-user.target` has on `wants`), because the dependency that `multi-user.target` has on
`network-online.target` is planned for removal. `network-online.target` is planned for removal.
- `services.pgbouncer` now has systemd support enabled and will log to journald. The default setting for `services.pgbouncer.logFile` is now `null` to disable logging to a separate log file.
- `services.archisteamfarm` no longer uses the abbreviation `asf` for its state directory (`/var/lib/asf`), user and group (both `asf`). Instead the long name `archisteamfarm` is used. - `services.archisteamfarm` no longer uses the abbreviation `asf` for its state directory (`/var/lib/asf`), user and group (both `asf`). Instead the long name `archisteamfarm` is used.
Configurations with `system.stateVersion` 23.11 or earlier, default to the old stateDirectory until the 24.11 release and must either set the option explicitly or move the data to the new directory. Configurations with `system.stateVersion` 23.11 or earlier, default to the old stateDirectory until the 24.11 release and must either set the option explicitly or move the data to the new directory.

View File

@ -66,9 +66,6 @@ let
${optionalString (cfg.adminUsers != null) "admin_users = ${cfg.adminUsers}"} ${optionalString (cfg.adminUsers != null) "admin_users = ${cfg.adminUsers}"}
${optionalString (cfg.statsUsers != null) "stats_users = ${cfg.statsUsers}"} ${optionalString (cfg.statsUsers != null) "stats_users = ${cfg.statsUsers}"}
# linux
pidfile = /run/pgbouncer/pgbouncer.pid
# extra # extra
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
@ -96,10 +93,9 @@ in {
logFile = mkOption { logFile = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = "pgbouncer.log"; default = null;
description = lib.mdDoc '' description = lib.mdDoc ''
Specifies the log file. Specifies a log file in addition to journald.
Either this or syslog has to be specified.
''; '';
}; };
@ -601,17 +597,16 @@ in {
systemd.services.pgbouncer = { systemd.services.pgbouncer = {
description = "PgBouncer - PostgreSQL connection pooler"; description = "PgBouncer - PostgreSQL connection pooler";
wants = [ "postgresql.service" ]; wants = [ "network-online.target" ] ++ lib.optional config.services.postgresql.enable "postgresql.service";
after = [ "postgresql.service" ]; after = [ "network-online.target" ] ++ lib.optional config.services.postgresql.enable "postgresql.service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
Type = "forking"; Type = "notify";
User = cfg.user; User = cfg.user;
Group = cfg.group; Group = cfg.group;
ExecStart = "${pkgs.pgbouncer}/bin/pgbouncer -d ${confFile}"; ExecStart = "${lib.getExe pkgs.pgbouncer} ${confFile}";
ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID"; ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
RuntimeDirectory = "pgbouncer"; RuntimeDirectory = "pgbouncer";
PIDFile = "/run/pgbouncer/pgbouncer.pid";
LimitNOFILE = cfg.openFilesLimit; LimitNOFILE = cfg.openFilesLimit;
}; };
}; };