aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/scripts/configurationPoller.sh
diff options
context:
space:
mode:
authorPawelSzalapski <pawel.szalapski@nokia.com>2018-08-02 10:31:56 +0200
committerPawelSzalapski <pawel.szalapski@nokia.com>2018-08-06 09:43:32 +0200
commit7752c2d818e6d19e4d805c2fd6760b4a13d601bc (patch)
tree053cbc5afd76a8b9644ec62298053aad8cf5e2a8 /src/main/scripts/configurationPoller.sh
parent654ebdff4c9ec2487b819d2b76273732759de4c7 (diff)
Implement second part of dynamic DMaaP config
VESCollector app can now fetch CBS configuration and rebuilt the part regarding sending events dynamically, without restarting application. Application will still be restarted by a .sh script, if there were changes regarding collector.properties file. The decision of whether dynamic configuration should be triggered is now based on existence of env vars CONSUL_HOST, CONFIG_BINDING_SERVICE, HOSTNAME, not as previously on CBSPOLLTIME. Frequency at which the config check should happen is now exposed via property from collector.properties Change-Id: I98ff160fa51d08d84a23c716d90ceaacbe17ada6 Signed-off-by: PawelSzalapski <pawel.szalapski@nokia.com> Issue-ID: DCAEGEN2-519
Diffstat (limited to 'src/main/scripts/configurationPoller.sh')
-rw-r--r--src/main/scripts/configurationPoller.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/scripts/configurationPoller.sh b/src/main/scripts/configurationPoller.sh
new file mode 100644
index 00000000..59dbf840
--- /dev/null
+++ b/src/main/scripts/configurationPoller.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+###
+# ============LICENSE_START=======================================================
+# PROJECT
+# ================================================================================
+# Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+source bin/logger.sh
+
+# This scripts job is to continuously run in background and watch for changes in collector.properties
+# and in case it has changed, restart application.
+# collector.properties (and DmaapConfig.json) is being updated periodically by calling for configuration from CBS and it is
+# done inside the VESCollector application itself.
+# Configuration poller can be run regardless of deployment type.
+# It will always check for changes in collector.properties and in deployment scenario,
+# where dynamic configuration should not be used, necessary environment
+# variables that are needed (consul host, cbs name, app name) will be missing, and java app will
+# not update the configuration files so restart won't be triggered.
+
+# Start after a while, because once the application starts, it might happen that
+# it fetched new configuration. In that case, the application will already be started with newest config, there would
+# be no point in restarting it once again.
+sleep 2m
+
+while true
+do
+ sleep 1m
+ if [[ $(find etc/collector.properties -mmin -1 -print) ]]; then
+ log "Found change in collector.properties, updating keystore and restarting application"
+ bin/appController.sh restart
+ fi
+done
+