Skip to content

Commit 31ec5dc

Browse files
committed
solr8 WIP use docker healthcheck
1 parent 629e6b3 commit 31ec5dc

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

docker/templates/docker-compose.development.yml

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ services:
2525
- /opt/solr/conf
2626
- "-Xms256m"
2727
- "-Xmx512m"
28+
healthcheck:
29+
# this is a backend test so port will always be 8983 - NOT the forwarded port
30+
test: ["CMD-SHELL", "curl -sf http://localhost:8983/solr/dcv/admin/ping?wt=json | grep -io \"OK\" || exit 1"]
31+
start_period: 5s
32+
interval: 2s
33+
timeout: 20s
34+
retries: 7
2835
fedora:
2936
build: ./fedora
3037
restart: always

docker/templates/docker-compose.test.yml

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ services:
2525
- /opt/solr/conf
2626
- "-Xms256m"
2727
- "-Xmx512m"
28+
healthcheck:
29+
# this is a backend test so port will always be 8983 - NOT the forwarded port
30+
test: ["CMD-SHELL", "curl -sf http://localhost:8983/solr/dcv/admin/ping?wt=json | grep -io \"OK\" || exit 1"]
31+
start_period: 5s
32+
interval: 2s
33+
timeout: 20s
34+
retries: 7
2835
fedora:
2936
build: ./fedora
3037
restart: always

lib/tasks/dcv/docker.rake

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ namespace :dcv do
1212

1313
def wait_for_solr_cores_to_load
1414
expected_port = docker_compose_config['services']['solr']['ports'][0].split(':')[0]
15-
Timeout.timeout(10, Timeout::Error, 'Timed out during solr startup check.') do
15+
solr_id = `docker compose -f #{Rails.root.join(docker_compose_file_path)} ps -q solr`
16+
17+
Timeout.timeout(20, Timeout::Error, 'Timed out during solr startup check.') do
1618
loop do
1719
sleep 0.25
18-
status_code = Net::HTTP.get_response(URI("http://localhost:#{expected_port}/solr/dcv/update?wt=json")).code
19-
break if status_code != '503'
20-
rescue EOFError, Errno::ECONNRESET
20+
status = `docker inspect --format "{{.State.Health.Status}}" #{solr_id}`.strip
21+
break if status == 'healthy'
22+
rescue EOFError
2123
next
2224
end
2325
end

0 commit comments

Comments
 (0)