From 6f99f3c284dac95630ee3c80a5f5582f2a5b3f24 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 7 Aug 2014 13:11:37 +1000 Subject: [PATCH] FEATURE: allow tweaking more pg setup options --- samples/data.yml | 6 ++++++ samples/standalone.yml | 7 +++++- templates/postgres.template.yml | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/samples/data.yml b/samples/data.yml index df4864f..ddb6228 100644 --- a/samples/data.yml +++ b/samples/data.yml @@ -16,6 +16,12 @@ env: # ensure locale exists in container, you may need to install it LANG: en_US.UTF-8 +params: + db_default_text_search_config: "pb_catelog.english" + ## Set db_shared_buffers to 1/3 of the memory you wish to allocate to postgres + ## on 1GB install set to 128MB on a 4GB instance you may raise to 1GB + # db_shared_buffers: "256MB" + # amend SOME_SECRET to a password for the discourse user hooks: after_postgres: diff --git a/samples/standalone.yml b/samples/standalone.yml index 70b1c8e..6b1aba0 100644 --- a/samples/standalone.yml +++ b/samples/standalone.yml @@ -19,7 +19,12 @@ expose: - "80:80" # fwd host port 80 to container port 80 (http) - "2222:22" # fwd host port 2222 to container port 22 (ssh) -#params: +params: + db_default_text_search_config: "pb_catelog.english" + ## Set db_shared_buffers to 1/3 of the memory you wish to allocate to postgres + ## on 1GB install set to 128MB on a 4GB instance you may raise to 1GB + #db_shared_buffers: "256MB" + # ## Which Git revision should this container use? (default: tests-passed) #version: tests-passed diff --git a/templates/postgres.template.yml b/templates/postgres.template.yml index abed0f4..21d6227 100644 --- a/templates/postgres.template.yml +++ b/templates/postgres.template.yml @@ -1,3 +1,9 @@ +params: + db_synchronous_commit: "off" + db_shared_buffers: "256MB" + db_work_mem: "10MB" + db_default_text_search_config: "pb_catelog.english" + hooks: after_cron: - file: @@ -107,6 +113,8 @@ run: - chown -R postgres:postgres /var/run/postgresql - exec: /root/upgrade_postgres + - exec: rm /root/upgrade_postgres + - replace: filename: "/etc/postgresql/9.3/main/postgresql.conf" from: "data_directory = '/var/lib/postgresql/9.3/main'" @@ -118,6 +126,36 @@ run: from: /#?listen_addresses *=.*/ to: "listen_addresses = '*'" + # listen on all interfaces + - replace: + filename: "/etc/postgresql/9.3/main/postgresql.conf" + from: /#?listen_addresses *=.*/ + to: "listen_addresses = '*'" + + # sync commit off is faster and less spiky, also marginally less safe + - replace: + filename: "/etc/postgresql/9.3/main/postgresql.conf" + from: /#?synchronous_commit *=.*/ + to: "synchronous_commit = $db_synchronous_commit" + + # default is 128MB which is way too small + - replace: + filename: "/etc/postgresql/9.3/main/postgresql.conf" + from: /#?shared_buffers *=.*/ + to: "shared_buffers = $db_shared_buffers" + + # default is 1MB which is too small + - replace: + filename: "/etc/postgresql/9.3/main/postgresql.conf" + from: /#?work_mem *=.*/ + to: "work_mem = $db_work_mem" + + # allow for other + - replace: + filename: "/etc/postgresql/9.3/main/postgresql.conf" + from: /#?default_text_search_config *=.*/ + to: "default_text_search_config = '$db_default_text_search_config'" + # Necessary to enable backups - exec: cmd: -- 2.25.1