A platform for community discussion. Free, open, simple.
DEV: Wait for initdb to complete in docker.rake (#15614)
David Taylored2f700440bb
diff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rakeindex 90bc68d040c..8a914d428fa 100644--- a/lib/tasks/docker.rake+++ b/lib/tasks/docker.rake@@ -102,8 +102,11 @@ task 'docker:test' doputs "Starting background redis"@redis_pid = Process.spawn('redis-server --dir tmp/test_data/redis')+ puts "Initializing postgres"+ system("script/start_test_db.rb --skip-run", exception: true)+puts "Starting postgres"- @pg_pid = Process.spawn("script/start_test_db.rb --exec")+ @pg_pid = Process.spawn("script/start_test_db.rb --skip-setup --exec")ENV["RAILS_ENV"] = "test"# this shaves all the creation of the multisite db offdiff --git a/script/start_test_db.rb b/script/start_test_db.rbindex 280a6347f28..f9a4d871c84 100755--- a/script/start_test_db.rb+++ b/script/start_test_db.rb@@ -8,23 +8,31 @@ def run(*args)system(*args, exception: true)end+should_setup = true+should_run = trueshould_exec = falsewhile 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 = trueelseraise "Unknown argument #{a}"endend-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"+endif should_execexec "#{BIN}/postmaster -D #{DATA}"-else+elsif should_runrun "#{BIN}/pg_ctl -D #{DATA} start"end