Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

420 B
Raw Blame
require "timeout"

timeout = (ENV["WAIT_FOR_DB_TIMEOUT_SECONDS"] || 120).to_i

Timeout::timeout(timeout) do
  loop do
    puts "[#{DateTime.now}] waiting for db to be ready and migrated"
    sleep 4

    begin
      ActiveRecord::Migration.check_all_pending!

      puts "[#{DateTime.now}] db ready"
      exit 0
    rescue StandardError => e
      puts "[#{DateTime.now}] not ready yet: #{e.message}"
    end
  end
end