From 01bdf7f46683f39718348c931a231e6afe71f156 Mon Sep 17 00:00:00 2001 From: Brian Kelley Date: Tue, 11 Dec 2018 13:47:42 -0600 Subject: [PATCH] Add Memcached caching setup and environment variable --- README.md | 2 ++ configuration.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/README.md b/README.md index d3f70e8..3e3b097 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ MASTER_NODE_NAME -- Enable clustering, when set this container will be the maste POD_NAME -- Enable Kubernetes clustering via downward API POD_IP -- Enable Kubernetes clustering via downward API +MEMCACHED_HOST -- Enable Memcached caching, assumes port 11211 by default + ``` ## Data Persistence diff --git a/configuration.sh b/configuration.sh index 295ed77..98431bf 100755 --- a/configuration.sh +++ b/configuration.sh @@ -96,6 +96,20 @@ setup_java_opts() { echo_time "\n\nJAVA_OPTS: $JAVA_OPTS \n\n" } +create_cache_properties(){ + echo_time "Setting up the cache.properties to be memcached" + cat <<-EOF > /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/dal/cache.properties +cache.type=memcached +EOF +} + +create_memcached_properties(){ + echo_time "Setting up the memcached.properties" + cat <<-EOF > /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/dal/memcached.properties +memcached.endpoints[0]=$MEMCACHED_HOST +EOF +} + ########################################################## # Arguments: # Cluster master node name / ip @@ -142,6 +156,14 @@ if [ ! -z "$MASTER_NODE_NAME" ]; then create_cluster_properties $MASTER_NODE_NAME fi +# Check for MEMCACHED_HOST environment variable to setup Memcached +if [ ! -z "$MEMCACHED_HOST" ]; then + echo_time "Memcached host is set, setup memcached settings" + create_cache_properties + + create_memcached_properties +fi + setup_stdout_logging setup_linux_logging_paths