|
120 | 120 | # OrioleDB: append orioledb to shared_preload_libraries |
121 | 121 | sed -i "s/\(shared_preload_libraries.*\)'\(.*\)$/\1, orioledb'\2/" $out/postgresql.conf |
122 | 122 | echo "default_table_access_method = 'orioledb'" >> $out/postgresql.conf |
123 | | - echo "orioledb.enable_rewind = true" >> $out/postgresql.conf |
124 | | - echo "orioledb.rewind_max_time = 1200" >> $out/postgresql.conf |
125 | | - echo "orioledb.rewind_max_transactions = 100000" >> $out/postgresql.conf |
126 | | - echo "orioledb.rewind_buffers = 1280" >> $out/postgresql.conf |
127 | 123 | '' |
128 | 124 | else |
129 | 125 | "" |
|
417 | 413 | makeOrioledbSpecialisation = |
418 | 414 | { |
419 | 415 | postgresPort ? defaultPort, |
| 416 | + extraConfig ? "", |
420 | 417 | }: |
421 | 418 | let |
422 | 419 | orioledbPkg = self.packages.${system}."psql_orioledb-17/bin"; |
@@ -446,35 +443,42 @@ let |
446 | 443 |
|
447 | 444 | # Runs as postgres: initdb with OrioleDB-specific args, config deployment, validation |
448 | 445 | initScript = pkgs.pkgsLinux.writeShellScript "postgresql-orioledb-init" '' |
449 | | - set -euo pipefail |
450 | | - DATA_DIR="${newDataDir}" |
451 | | -
|
452 | | - if [ ! -f "$DATA_DIR/PG_VERSION" ]; then |
453 | | - echo "Initializing OrioleDB database at $DATA_DIR" |
454 | | - ${orioledbPkg}/bin/initdb \ |
455 | | - --allow-group-access --data-checksums \ |
456 | | - --locale-provider=icu --encoding=UTF-8 --icu-locale=en_US.UTF-8 \ |
457 | | - -U supabase_admin -D "$DATA_DIR" |
458 | | - fi |
459 | | -
|
460 | | - # Deploy processed config files with @dataDir@ substituted |
461 | | - for f in postgresql.conf pg_hba.conf pg_ident.conf supautils.conf read-replica.conf; do |
462 | | - sed "s|@dataDir@|$DATA_DIR|g" ${processedConfig}/$f > "$DATA_DIR/$f" |
463 | | - done |
464 | | -
|
465 | | - # Copy conf.d directory |
466 | | - rm -rf "$DATA_DIR/conf.d" |
467 | | - cp -r ${processedConfig}/conf.d "$DATA_DIR/conf.d" |
468 | | - chmod -R u+w "$DATA_DIR/conf.d" |
469 | | -
|
470 | | - # Copy extension-custom-scripts directory |
471 | | - rm -rf "$DATA_DIR/extension-custom-scripts" |
472 | | - cp -r ${processedConfig}/extension-custom-scripts "$DATA_DIR/extension-custom-scripts" |
473 | | - chmod -R u+w "$DATA_DIR/extension-custom-scripts" |
474 | | -
|
475 | | - # Validate config |
476 | | - echo "Validating PostgreSQL configuration..." |
477 | | - ${orioledbPkg}/bin/postgres -C shared_preload_libraries -D "$DATA_DIR" |
| 446 | + set -euo pipefail |
| 447 | + DATA_DIR="${newDataDir}" |
| 448 | +
|
| 449 | + if [ ! -f "$DATA_DIR/PG_VERSION" ]; then |
| 450 | + echo "Initializing OrioleDB database at $DATA_DIR" |
| 451 | + ${orioledbPkg}/bin/initdb \ |
| 452 | + --allow-group-access --data-checksums \ |
| 453 | + --locale-provider=icu --encoding=UTF-8 --icu-locale=en_US.UTF-8 \ |
| 454 | + -U supabase_admin -D "$DATA_DIR" |
| 455 | + fi |
| 456 | +
|
| 457 | + # Deploy processed config files with @dataDir@ substituted |
| 458 | + for f in postgresql.conf pg_hba.conf pg_ident.conf supautils.conf read-replica.conf; do |
| 459 | + sed "s|@dataDir@|$DATA_DIR|g" ${processedConfig}/$f > "$DATA_DIR/$f" |
| 460 | + done |
| 461 | +
|
| 462 | + # Append any extra configuration |
| 463 | + if [ -n '${extraConfig}' ]; then |
| 464 | + cat >> "$DATA_DIR/postgresql.conf" << 'EXTRA_CONFIG_EOF' |
| 465 | + ${extraConfig} |
| 466 | + EXTRA_CONFIG_EOF |
| 467 | + fi |
| 468 | +
|
| 469 | + # Copy conf.d directory |
| 470 | + rm -rf "$DATA_DIR/conf.d" |
| 471 | + cp -r ${processedConfig}/conf.d "$DATA_DIR/conf.d" |
| 472 | + chmod -R u+w "$DATA_DIR/conf.d" |
| 473 | +
|
| 474 | + # Copy extension-custom-scripts directory |
| 475 | + rm -rf "$DATA_DIR/extension-custom-scripts" |
| 476 | + cp -r ${processedConfig}/extension-custom-scripts "$DATA_DIR/extension-custom-scripts" |
| 477 | + chmod -R u+w "$DATA_DIR/extension-custom-scripts" |
| 478 | +
|
| 479 | + # Validate config |
| 480 | + echo "Validating PostgreSQL configuration..." |
| 481 | + ${orioledbPkg}/bin/postgres -C shared_preload_libraries -D "$DATA_DIR" |
478 | 482 | ''; |
479 | 483 |
|
480 | 484 | # Full db init: CREATE EXTENSION orioledb first, then init-scripts + migrations |
|
549 | 553 | }; |
550 | 554 |
|
551 | 555 | # Override postgresql: new package, new data dir, new ExecStartPre for orioledb initdb |
| 556 | + # Restart settings match production: ansible/files/postgresql_config/postgresql.service |
552 | 557 | systemd.services.postgresql = { |
553 | 558 | after = [ "postgresql-migrate.service" ]; |
554 | 559 | requires = [ "postgresql-migrate.service" ]; |
|
558 | 563 | initScript |
559 | 564 | ]; |
560 | 565 | ExecStart = lib.mkForce "${orioledbPkg}/bin/postgres -D ${newDataDir}"; |
| 566 | + Restart = "always"; |
| 567 | + RestartSec = "5"; |
561 | 568 | }; |
562 | 569 | environment = { |
563 | 570 | GRN_PLUGINS_DIR = lib.mkForce "${groongaPackage}/lib/groonga/plugins"; |
|
0 commit comments