solr: modify startup script to include special args

This commit is contained in:
Brendan Early
2021-05-10 19:48:34 -05:00
parent a61c121b27
commit 24410adac8
3 changed files with 89 additions and 3 deletions

View File

@@ -11,3 +11,12 @@ data:
{{ load_file('packages/solrconfig.xml') | indent }}
schema.xml: |-
{{ load_file('packages/schema.xml') | indent }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: solr-start-configmap
labels:
app: solr
solr-start.sh: |-
{{ load_file('solr-start.sh') | indent }}

View File

@@ -23,9 +23,8 @@ spec:
- name: solr
image: solr:8
command:
- solr-precreate
args:
- packages
- bash
- /opt/solr-start/solr-start.sh
ports:
- containerPort: 8983
resources: {}
@@ -35,6 +34,8 @@ spec:
- name: config-volume
mountPath: /opt/solr/server/solr/configsets/packages
readOnly: true
- name: script-volume
mountpath: /opt/solr-start
readinessProbe:
timeoutSeconds: 1
initialDelaySeconds: 30
@@ -54,6 +55,9 @@ spec:
- name: config-volume
configMap:
name: solr-configmap
- name: script-volume
configMap:
name: solr-start-configmap
triggers:
- type: ConfigChange

View File

@@ -0,0 +1,73 @@
#!/bin/bash
#
# Taken from https://github.com/docker-solr/docker-solr/blob/master/scripts/solr-precreate
# Chnaged so that Solr itself is called with -p 8983 (otherwise it will crash).
set -e
if [[ "${VERBOSE:-}" == "yes" ]]; then
set -x
fi
# init script for handling an empty /var/solr
/opt/docker-solr/scripts/init-var-solr
. /opt/docker-solr/scripts/run-initdb
/opt/docker-solr/scripts/precreate-core "packages"
#!/bin/bash
#
# start solr in the foreground
set -e
if [[ "$VERBOSE" == "yes" ]]; then
set -x
fi
EXTRA_ARGS=()
EXTRA_ARGS+=(-a '-p 8983')
# Start of https://github.com/docker-solr/docker-solr/blob/master/scripts/solr-fg
if [[ -z "${OOM:-}" ]]; then
OOM='none'
fi
case "$OOM" in
'script')
EXTRA_ARGS+=(-a '-XX:OnOutOfMemoryError=/opt/docker-solr/scripts/oom_solr.sh')
;;
'exit')
# recommended
EXTRA_ARGS+=(-a '-XX:+ExitOnOutOfMemoryError')
;;
'crash')
EXTRA_ARGS+=(-a '-XX:+CrashOnOutOfMemoryError')
;;
'none'|'')
;;
*)
echo "Unsupported value in OOM=$OOM"
exit 1
esac
echo "Starting Solr $SOLR_VERSION"
# determine TINI default. If it is already set, assume the user knows what they want
if [[ -z "${TINI:-}" ]]; then
if [[ "$$" == 1 ]]; then
# Default to running tini, so we can run with an OOM script and have 'kill -9' work
TINI=yes
else
# Presumably we're already running under tini through 'docker --init', in which case we
# don't need to run it twice.
# It's also possible that we're run from a wrapper script without exec,
# in which case running tini would not be ideal either.
TINI=no
fi
fi
if [[ "$TINI" == yes ]]; then
exec /usr/bin/tini -- solr -f "$@" "${EXTRA_ARGS[@]}"
elif [[ "$TINI" == no ]]; then
exec solr -f "$@" "${EXTRA_ARGS[@]}"
else
echo "invalid value TINI=$TINI"
exit 1
fi