about summary refs log tree commit diff
path: root/nixos/modules/services/databases
diff options
context:
space:
mode:
authorSophie Tauchert <sophie@999eagle.moe>2024-02-02 19:35:01 +0100
committerSophie Tauchert <sophie@999eagle.moe>2024-02-15 21:42:27 +0100
commitb89cd583aedd1d4dff6dc1b763d498ab05bb4941 (patch)
tree21ca92d1e062284be0f4f6337c49fc23d6e6451a /nixos/modules/services/databases
parentb3f483a5c22134294727b253603a9f6441c638e8 (diff)
downloadnixlib-b89cd583aedd1d4dff6dc1b763d498ab05bb4941.tar
nixlib-b89cd583aedd1d4dff6dc1b763d498ab05bb4941.tar.gz
nixlib-b89cd583aedd1d4dff6dc1b763d498ab05bb4941.tar.bz2
nixlib-b89cd583aedd1d4dff6dc1b763d498ab05bb4941.tar.lz
nixlib-b89cd583aedd1d4dff6dc1b763d498ab05bb4941.tar.xz
nixlib-b89cd583aedd1d4dff6dc1b763d498ab05bb4941.tar.zst
nixlib-b89cd583aedd1d4dff6dc1b763d498ab05bb4941.zip
nixos/pgbouncer: only depend on postgresql.service when enabled and use notify
See also the upstream service file: https://github.com/pgbouncer/pgbouncer/blob/e6ce619785c93392794976c1e936e8c9f589a5ad/etc/pgbouncer.service
Diffstat (limited to 'nixos/modules/services/databases')
-rw-r--r--nixos/modules/services/databases/pgbouncer.nix17
1 files changed, 6 insertions, 11 deletions
diff --git a/nixos/modules/services/databases/pgbouncer.nix b/nixos/modules/services/databases/pgbouncer.nix
index 65b287e84442..4dee50a2a192 100644
--- a/nixos/modules/services/databases/pgbouncer.nix
+++ b/nixos/modules/services/databases/pgbouncer.nix
@@ -66,9 +66,6 @@ let
       ${optionalString (cfg.adminUsers != null) "admin_users = ${cfg.adminUsers}"}
       ${optionalString (cfg.statsUsers != null) "stats_users = ${cfg.statsUsers}"}
 
-      # linux
-      pidfile = /run/pgbouncer/pgbouncer.pid
-
       # extra
       ${cfg.extraConfig}
     '';
@@ -96,10 +93,9 @@ in {
 
     logFile = mkOption {
       type = types.nullOr types.str;
-      default = "pgbouncer.log";
+      default = null;
       description = lib.mdDoc ''
-        Specifies the log file.
-        Either this or syslog has to be specified.
+        Specifies a log file in addition to journald.
       '';
     };
 
@@ -601,17 +597,16 @@ in {
 
     systemd.services.pgbouncer = {
       description = "PgBouncer - PostgreSQL connection pooler";
-      wants    = [ "postgresql.service" ];
-      after    = [ "postgresql.service" ];
+      wants    = [ "network-online.target" ] ++ lib.optional config.services.postgresql.enable "postgresql.service";
+      after    = [ "network-online.target" ] ++ lib.optional config.services.postgresql.enable "postgresql.service";
       wantedBy = [ "multi-user.target" ];
       serviceConfig = {
-        Type = "forking";
+        Type = "notify";
         User = cfg.user;
         Group = cfg.group;
-        ExecStart = "${pkgs.pgbouncer}/bin/pgbouncer -d ${confFile}";
+        ExecStart = "${lib.getExe pkgs.pgbouncer} ${confFile}";
         ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
         RuntimeDirectory = "pgbouncer";
-        PIDFile = "/run/pgbouncer/pgbouncer.pid";
         LimitNOFILE = cfg.openFilesLimit;
       };
     };