Skip to content

Commit eee765a

Browse files
authored
DEV-1119: create healthcheck endpoint (#8)
iipsrv provides a 'homepage' that can serve as a healthcheck for the service. however, it wasn't routable using our older nginx config. this adds another route for that, and adds associated tests and fixtures.
1 parent 4f547d8 commit eee765a

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

nginx/nginx.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,20 @@ server {
1919
fastcgi_param SERVER_PROTOCOL $server_protocol;
2020
fastcgi_param REQUEST_URI $request_uri;
2121
}
22+
23+
# this is a workaround to get iipsrv's default "homepage"
24+
# to work as a healthcheck that's not tied to any specific
25+
# image resource. it intentionally overrides PATH_INFO
26+
# and does not send QUERY_STRING.
27+
#
28+
# @see ruven/iipsrv#190
29+
location /health {
30+
fastcgi_pass 127.0.0.1:9000;
31+
fastcgi_param PATH_INFO /;
32+
fastcgi_param REQUEST_METHOD $request_method;
33+
fastcgi_param CONTENT_TYPE $content_type;
34+
fastcgi_param CONTENT_LENGTH $content_length;
35+
fastcgi_param SERVER_PROTOCOL $server_protocol;
36+
fastcgi_param REQUEST_URI $request_uri;
37+
}
2238
}

test/health.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>IIPImage Server</title><meta name="DC.creator" content="Ruven Pillay &lt;ruven@users.sourceforge.net&gt;"/><meta name="DC.title" content="IIPImage Server"/><meta name="DC.source" content="https://iipimage.sourceforge.io"/></head><body style="font-family:Helvetica,sans-serif; margin:4em"><center><h1>IIPImage Server</h1><h2>Version 1.3</h2><br/><h3>Project Home Page: <a href="https://iipimage.sourceforge.io">https://iipimage.sourceforge.io</a></h3><br/><h4>by<br/>Ruven Pillay</h4></center></body></html>

test/test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ assert_identical() {
4747
############################################################
4848
# Fixture
4949

50+
HEALTHCHECK_URL='http://localhost/health'
5051
INFO_URL='http://localhost/iiif/test.tif/info.json'
5152
IMAGE_URL='http://localhost/iiif/test.tif/full/64,/0/default.jpg'
5253

54+
EXPECTED_HEALTHCHECK_PATH="test/health.html"
5355
EXPECTED_INFO_PATH="test/info.json"
5456
EXPECTED_IMAGE_PATH="test/default.jpg"
5557

5658
ARTIFACTS_DIR="artifacts"
59+
ACTUAL_HEALTHCHECK_PATH="${ARTIFACTS_DIR}/health.html"
5760
ACTUAL_INFO_PATH="${ARTIFACTS_DIR}/info.json"
5861
ACTUAL_IMAGE_PATH="${ARTIFACTS_DIR}/default.jpg"
5962

@@ -73,6 +76,17 @@ echo
7376
############################################################
7477
# Tests
7578

79+
echo '------------------------------------------------------------'
80+
echo 'Making healthcheck request:'
81+
echo
82+
download "${HEALTHCHECK_URL}" "${ACTUAL_HEALTHCHECK_PATH}"
83+
echo
84+
85+
echo '------------------------------------------------------------'
86+
echo 'Verifying healthcheck result:'
87+
echo
88+
assert_identical "${EXPECTED_HEALTHCHECK_PATH}" "${ACTUAL_HEALTHCHECK_PATH}"
89+
7690
echo '------------------------------------------------------------'
7791
echo 'Making IIIF info request:'
7892
echo

0 commit comments

Comments
 (0)