-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #509 from jcantrill/mem_for_kibana_36
Merged by openshift-bot
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,53 @@ | ||
#!/bin/sh | ||
set -euo pipefail | ||
|
||
# add host and port to config | ||
sed -i "s/es_host/$ES_HOST/" ${KIBANA_HOME}/config/kibana.yml | ||
sed -i "s/es_port/$ES_PORT/" ${KIBANA_HOME}/config/kibana.yml | ||
|
||
# override styles for branding | ||
if [ -f "/etc/openshift/kibana/styles/overrides.css" ]; then | ||
cp -f /etc/openshift/kibana/styles/overrides.css ${KIBANA_HOME}/installedPlugins/origin-kibana/public/styles | ||
rm -rf ${KIBANA_HOME}/optimize/bundles/** | ||
fi | ||
|
||
# override images for branding | ||
if [ -d "/etc/openshift/kibana/images" ]; then | ||
cp -f /etc/openshift/kibana/images/* ${KIBANA_HOME}/installedPlugins/origin-kibana/public/images | ||
fi | ||
|
||
#set the max memory | ||
BYTES_PER_MEG=$((1024*1024)) | ||
BYTES_PER_GIG=$((1024*${BYTES_PER_MEG})) | ||
|
||
DEFAULT_MIN=$((128 * $BYTES_PER_MEG)) #This is a guess | ||
regex='^([[:digit:]]+)([GgMm])?i?$' | ||
|
||
export NODE_OPTIONS="" | ||
|
||
if [[ "${KIBANA_MEMORY_LIMIT:-}" =~ $regex ]]; then | ||
num=${BASH_REMATCH[1]} | ||
unit=${BASH_REMATCH[2]} | ||
|
||
if [[ $unit =~ [Gg] ]]; then | ||
((num = num * ${BYTES_PER_GIG})) # enables math to work out for odd Gi | ||
elif [[ $unit =~ [Mm] ]]; then | ||
((num = num * ${BYTES_PER_MEG})) # enables math to work out for odd Gi | ||
#else assume bytes | ||
fi | ||
|
||
if [[ $num -lt $DEFAULT_MIN ]] ; then | ||
echo "$num is less then the default $(($DEFAULT_MIN / $BYTES_PER_MEG))m. Setting to default." | ||
((num = $DEFAULT_MIN)) | ||
fi | ||
|
||
export NODE_OPTIONS="--max_old_space_size=$((num / ${BYTES_PER_MEG}))" | ||
|
||
else | ||
echo "Unable to process the KIBANA_MEMORY_LIMIT: '${KIBANA_MEMORY_LIMIT}'. It must be in the format of: /${regex}/" | ||
exit 1 | ||
fi | ||
|
||
echo "Using NODE_OPTIONS: '$NODE_OPTIONS' Memory setting is in MB" | ||
|
||
exec ${KIBANA_HOME}/bin/kibana |