Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
129 lines (127 loc) · 6.35 KB
/
Copy pathdocker-compose.yml
File metadata and controls
129 lines (127 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# The reasons behind these settings are in doc/deployment-rationale.md; read the
# relevant section there before changing one. Instance-specific values go into
# docker-compose.override.yml and .env (see docker-compose.override.yml.template).
# The fleet deploys from nanopub-infrastructure/nanopub-query/; keep the two in sync.
services:
query:
build: .
image: nanopub/query:${NANOPUB_QUERY_IMAGE_TAG:-latest}
restart: unless-stopped
ports:
# Localhost only: no authentication, and /repo requests of every method
# reach RDF4J (rationale: #ports-bound-to-localhost).
- "127.0.0.1:9393:9393"
# :9394 is only accessible from localhost as it is used for the /metrics endpoint
- "127.0.0.1:9394:9394"
volumes:
# For the local nanopub loader (optional).
# If not used, Query will load the nanopubs from the Registry with Jelly.
- ./load:/app/load
environment:
- ENDPOINT_TYPE=rdf4j
- ENDPOINT_BASE=http://rdf4j:8080/rdf4j-server/
- REGISTRY_FIXED_URL=https://registry.knowledgepixels.com/
- RDF4J_PROXY_HOST=rdf4j
# Server-side SPARQL evaluation limit in seconds; 0 disables
# (rationale: #query-timeout).
- RDF4J_QUERY_TIMEOUT_SECONDS=${RDF4J_QUERY_TIMEOUT_SECONDS:-60}
# Socket timeout (ms) for the app's own reads from RDF4J; keep in step with
# the default in Utils.getHttpRequestConfig (rationale: #fetching-socket-timeout).
- NANOPUB_QUERY_FETCHING_SOCKET_TIMEOUT=${NANOPUB_QUERY_FETCHING_SOCKET_TIMEOUT:-30000}
# One-shot repair: re-stream the whole registry at startup. Only on a wiped
# or out-of-rotation instance, for one `up -d` (rationale: #force_resync).
- FORCE_RESYNC=${FORCE_RESYNC:-false}
# Stop the app before RDF4J, so no write is in flight when the store goes down
# (rationale: #shutdown-order-and-grace-periods).
depends_on:
- rdf4j
# Must stay above NANOPUB_QUERY_SHUTDOWN_QUIESCE_SECONDS (90 s); raise both
# together (rationale: #shutdown-order-and-grace-periods).
stop_grace_period: 150s
logging:
options:
max-size: "10m"
max-file: "3"
rdf4j:
# rdf4j 6.0.0 with the eclipse-rdf4j/rdf4j#5974 fixes. Neither stock 6.0.0 (store
# corruption) nor 6.1.0 (query-planning regression) is safe for this workload;
# 5.x -> 6.x needs a wipe and re-ingest (rationale: #rdf4j-version). Override
# RDF4J_IMAGE and RDF4J_IMAGE_TAG together: official releases are published as
# eclipse/rdf4j-workbench.
image: ${RDF4J_IMAGE:-nanopub/rdf4j-workbench}:${RDF4J_IMAGE_TAG:-6.0.0-lmdbpool4}
restart: unless-stopped
# Root, so init.sh can install curl and re-chown the volumes; it drops to the
# tomcat user before starting the JVM.
user: "0"
environment:
# Pool sizes for federated SERVICE calls: lowering them makes the federation
# deadlock MORE likely (rationale: #federation-connection-pool-and-tomcat-threads).
# OOM handling, heap size and lock diagnostics: #jvm-options-for-rdf4j.
- JAVA_OPTS=-XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/info/ -XX:MaxRAMPercentage=${RDF4J_MAX_RAM_PERCENTAGE:-50} -XX:+PrintConcurrentLocks -Dorg.eclipse.rdf4j.client.http.connectionTimeout=10000 -Dorg.eclipse.rdf4j.client.http.connectionRequestTimeout=10000 -Dorg.eclipse.rdf4j.client.http.socketTimeout=10000 -Dorg.eclipse.rdf4j.client.http.maxConnPerRoute=${RDF4J_MAX_CONN_PER_ROUTE:-120} -Dorg.eclipse.rdf4j.client.http.maxConnTotal=${RDF4J_MAX_CONN_TOTAL:-240}
# Tomcat worker threads (set by init.sh); must stay >= 2x maxConnPerRoute.
- RDF4J_TOMCAT_MAX_THREADS=${RDF4J_TOMCAT_MAX_THREADS:-240}
# For the healthcheck's federation probe; explicitly empty disables it.
- NANOPUB_QUERY_INTERNAL_URL=${NANOPUB_QUERY_INTERNAL_URL-http://query:9393/}
# Whether a failing healthcheck may restart Tomcat; off by default
# (rationale: #healthcheck).
- RDF4J_HEALTHCHECK_RESTART=${RDF4J_HEALTHCHECK_RESTART:-off}
volumes:
- ./data/rdf4j/data:/var/rdf4j
- ./data/rdf4j/logs:/usr/local/tomcat/logs
- ./data/info:/var/info
- ./entrypoint:/var/entrypoint
ports:
# Localhost only: no authentication, and every repository is writable
# (rationale: #ports-bound-to-localhost).
- "127.0.0.1:8081:8080"
entrypoint: /var/entrypoint/init.sh
# A clean shutdown closes thousands of LMDB repos and takes ~100 s
# (rationale: #shutdown-order-and-grace-periods).
stop_grace_period: 120s
healthcheck:
# Direct-query probe plus federation-route probe; restarts are suppressed
# unless RDF4J_HEALTHCHECK_RESTART=on (rationale: #healthcheck).
test: |
restart_tomcat() {
if [ "$$RDF4J_HEALTHCHECK_RESTART" != "on" ]; then
date >> /var/info/restart-suppressed
return
fi
if [ -f /var/info/restart ]; then
last_s=$$(date -d "$$(tail -1 /var/info/restart)" +%s 2>/dev/null || echo 0)
if [ $$(( $$(date +%s) - last_s )) -lt 600 ]; then
return
fi
fi
date >> /var/info/restart
pkill -15 java
i=0
while [ $$i -lt 12 ] && pgrep java > /dev/null; do
sleep 5
i=$$((i + 1))
done
if pgrep java > /dev/null; then
pkill -9 java
fi
}
if ! curl -fsS --retry 2 --max-time 10 --retry-delay 2 --retry-max-time 10 --retry-connrefused \
"http://localhost:8080/rdf4j-server/repositories/full?query=select%2Awhere%7B%3Fs%3Cx%3A%3E%3Fo%7Dlimit1" > /dev/null; then
if [ -f /var/info/ready ]; then
restart_tomcat
fi
exit 1
fi
touch /var/info/ready
if [ -n "$$NANOPUB_QUERY_INTERNAL_URL" ]; then
if ! curl -fsS --retry 2 --max-time 12 --retry-delay 2 \
--data-urlencode "query=select ?s where { service <$${NANOPUB_QUERY_INTERNAL_URL}repo/meta> { select ?s where { ?s ?p ?o } limit 1 } }" \
"http://localhost:8080/rdf4j-server/repositories/spaces" > /dev/null; then
date >> /var/info/federation-restart
restart_tomcat
exit 1
fi
fi
exit 0
interval: 60s
timeout: 60s
start_period: 300s