mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Wait for initdb to complete in docker.rake (#15614)
On slower hardware it can take a while to init the database. If we don't wait, the `rake db:create` step will fail.
This commit is contained in:
@ -8,23 +8,31 @@ def run(*args)
|
||||
system(*args, exception: true)
|
||||
end
|
||||
|
||||
should_setup = true
|
||||
should_run = true
|
||||
should_exec = false
|
||||
while a = ARGV.pop
|
||||
if a == "--exec"
|
||||
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
|
||||
|
||||
run "#{BIN}/initdb -D #{DATA}"
|
||||
if should_setup
|
||||
run "#{BIN}/initdb -D #{DATA}"
|
||||
|
||||
run "echo fsync = off >> #{DATA}/postgresql.conf"
|
||||
run "echo full_page_writes = off >> #{DATA}/postgresql.conf"
|
||||
run "echo shared_buffers = 500MB >> #{DATA}/postgresql.conf"
|
||||
run "echo fsync = 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}/postmaster -D #{DATA}"
|
||||
else
|
||||
elsif should_run
|
||||
run "#{BIN}/pg_ctl -D #{DATA} start"
|
||||
end
|
||||
|
Reference in New Issue
Block a user