2 db_synchronous_commit: "off"
3 db_shared_buffers: "512MB"
5 db_default_text_search_config: "pg_catalog.english"
9 db_checkpoint_segments: 6
10 db_logging_collector: off
11 db_log_min_duration_statement: 100
16 filename: /etc/service/unicorn/run
18 to: sv start postgres || exit 1
24 - exec: mkdir -p /shared/postgres_run
25 - exec: chown postgres:postgres /shared/postgres_run
26 - exec: chmod 775 /shared/postgres_run
27 - exec: rm -fr /var/run/postgresql
28 - exec: ln -s /shared/postgres_run /var/run/postgresql
29 - exec: rm -fr /shared/postgres_run/.s*
30 - exec: rm -fr /shared/postgres_run/*.pid
31 - exec: mkdir -p /shared/postgres_run/9.3-main.pg_stat_tmp
32 - exec: chown postgres:postgres /shared/postgres_run/9.3-main.pg_stat_tmp
34 path: /etc/service/postgres/run
39 HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/9.3/bin/postmaster -D /etc/postgresql/9.3/main
42 path: /etc/runit/3.d/99-postgres
50 - chown -R root /var/lib/postgresql/9.3/main
51 - "[ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -E -u postgres LANG=en_US.UTF-8 /usr/lib/postgresql/9.3/bin/initdb --locale=C -E UTF-8 -D /shared/postgres_data || exit 0"
52 - chown -R postgres:postgres /shared/postgres_data
53 - chown -R postgres:postgres /var/run/postgresql
56 filename: "/etc/postgresql/9.3/main/postgresql.conf"
57 from: "data_directory = '/var/lib/postgresql/9.3/main'"
58 to: "data_directory = '/shared/postgres_data'"
60 # listen on all interfaces
62 filename: "/etc/postgresql/9.3/main/postgresql.conf"
63 from: /#?listen_addresses *=.*/
64 to: "listen_addresses = '*'"
66 # sync commit off is faster and less spiky, also marginally less safe
68 filename: "/etc/postgresql/9.3/main/postgresql.conf"
69 from: /#?synchronous_commit *=.*/
70 to: "synchronous_commit = $db_synchronous_commit"
72 # default is 128MB which is way too small
74 filename: "/etc/postgresql/9.3/main/postgresql.conf"
75 from: /#?shared_buffers *=.*/
76 to: "shared_buffers = $db_shared_buffers"
78 # default is 1MB which is too small
80 filename: "/etc/postgresql/9.3/main/postgresql.conf"
81 from: /#?work_mem *=.*/
82 to: "work_mem = $db_work_mem"
86 filename: "/etc/postgresql/9.3/main/postgresql.conf"
87 from: /#?default_text_search_config *=.*/
88 to: "default_text_search_config = '$db_default_text_search_config'"
90 # Necessary to enable backups
93 - install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
96 filename: "/etc/postgresql/9.3/main/postgresql.conf"
97 from: /#?max_wal_senders *=.*/
98 to: "max_wal_senders = $db_max_wal_senders"
101 filename: "/etc/postgresql/9.3/main/postgresql.conf"
102 from: /#?wal_level *=.*/
103 to: "wal_level = $db_wal_level"
106 filename: "/etc/postgresql/9.3/main/postgresql.conf"
107 from: /#?checkpoint_segments *=.*/
108 to: "checkpoint_segments = $db_checkpoint_segments"
111 filename: "/etc/postgresql/9.3/main/postgresql.conf"
112 from: /#?logging_collector *=.*/
113 to: "logging_collector = $db_logging_collector"
116 filename: "/etc/postgresql/9.3/main/postgresql.conf"
117 from: /#?log_min_duration_statement *=.*/
118 to: "log_min_duration_statement = $db_log_min_duration_statement"
121 filename: "/etc/postgresql/9.3/main/pg_hba.conf"
122 from: /^#local +replication +postgres +peer$/
123 to: "local replication postgres peer"
125 # allow all to connect in with md5 auth
127 filename: "/etc/postgresql/9.3/main/pg_hba.conf"
128 from: /^host.*all.*all.*127.*$/
129 to: "host all all 0.0.0.0/0 md5"
133 # use fast shutdown for pg
135 cmd: HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/9.3/bin/postmaster -D /etc/postgresql/9.3/main
137 # give db a few secs to start up
140 - exec: sudo -E -u postgres LANG=en_US.UTF-8 createdb discourse_development
141 - exec: sudo -E -u postgres LANG=en_US.UTF-8 createdb discourse_test
142 - exec: su postgres -c 'psql -c "create user $db_user with superuser"'
146 cmd: exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf
148 - exec: cd /var/www/discourse && sudo -u discourse rake db:migrate
149 - exec: cd /var/www/discourse && sudo -u discourse RAILS_ENV=test rake db:migrate
152 cmd: "echo postgres installed!"