mirror of
https://github.com/discourse/discourse.git
synced 2024-12-31 03:43:49 +08:00
23738541da
Why this change? In https://www.postgresql.org/docs/current/non-durability.html, it is recommended to turn off `synchronous_commit` in environments where durability is not important. The `start_test_db.rb` script is mainly used in the CI environment where durability is not important at all.
42 lines
913 B
Ruby
Executable File
42 lines
913 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
BIN = "/usr/lib/postgresql/#{ENV["PG_MAJOR"]}/bin"
|
|
DATA = "/tmp/test_data/pg"
|
|
|
|
def run(*args)
|
|
system(*args, exception: true)
|
|
end
|
|
|
|
should_setup = true
|
|
should_run = true
|
|
should_exec = false
|
|
while a = ARGV.pop
|
|
if a == "--skip-setup"
|
|
should_setup = false
|
|
elsif a == "--skip-run"
|
|
should_run = false
|
|
elsif a == "--exec"
|
|
should_exec = true
|
|
else
|
|
raise "Unknown argument #{a}"
|
|
end
|
|
end
|
|
|
|
if should_setup
|
|
run "rm -rf #{DATA}"
|
|
run "mkdir -p #{DATA}"
|
|
run "#{BIN}/initdb -D #{DATA}"
|
|
|
|
run "echo fsync = off >> #{DATA}/postgresql.conf"
|
|
run "echo synchronous_commit = off >> #{DATA}/postgresql.conf"
|
|
run "echo full_page_writes = off >> #{DATA}/postgresql.conf"
|
|
run "echo shared_buffers = 500MB >> #{DATA}/postgresql.conf"
|
|
end
|
|
|
|
if should_exec
|
|
exec "#{BIN}/postgres -D #{DATA}"
|
|
elsif should_run
|
|
run "#{BIN}/pg_ctl -D #{DATA} start"
|
|
end
|