From ef5cfe6f4f78de22bddc6d06e2c5e4497d081cd8 Mon Sep 17 00:00:00 2001 From: iuliana Date: Sun, 12 Sep 2021 21:55:29 +0100 Subject: [PATCH] Added more configuration for nginx --- catalog/common-types/nginx.bom | 67 +++++++++++++++++-- .../three-tier-webapp/three-tier-webapp.bom | 12 ++++ 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/catalog/common-types/nginx.bom b/catalog/common-types/nginx.bom index c00fecc..486b9da 100644 --- a/catalog/common-types/nginx.bom +++ b/catalog/common-types/nginx.bom @@ -40,12 +40,14 @@ brooklyn.catalog: To have the orchestration server download it, or to use a classpath URL with a bundled resource, use files.customize writing from that URL to creation-script.sql instead of this. type: string - default: 8080 + default: 80 - name: nginx.sticky description: Whether to use sticky sessions (no sure where this is used) type: boolean default: true - + - name: server.list + type: string + description: Comma separated list of server ips to manage. brooklyn.config: dontRequireTtyForSudo: true start.timeout: 20m @@ -54,21 +56,74 @@ brooklyn.catalog: shell.env: APP_PORT: $brooklyn:config("app.port") + ADDR_LIST: $brooklyn:config("server.list") install.command: | sudo apt -y update sudo apt -y install nginx customize.command: | - echo customize + sudo systemctl status nginx | grep 'running' > /dev/null 2>&1 + if [ $? == 0 ]; then + echo "NginX is up. All is well with the world..." + else + echo "NginX is down. Starting it..." + sudo systemctl start nginx + fi + + echo "NginX - configuring ..." + + cat >/tmp/load-balancer.conf < /dev/null 2>&1 + if [ $? == 0 ]; then + echo "NginX is up. All is well with the world." + else + echo "NginX is down. Starting it..." + sudo systemctl start nginx + fi stop.command: | - sudo systemctl stop nginx + sudo systemctl status nginx | grep 'running' > /dev/null 2>&1 + if [ $? == 0 ]; then + echo "NginX is up. Shutting it down..." + sudo systemctl stop nginx + else + echo "NginX is already down." + fi checkRunning.command: sudo systemctl status nginx | grep -i -e 'active' -e 'online' diff --git a/catalog/three-tier-webapp/three-tier-webapp.bom b/catalog/three-tier-webapp/three-tier-webapp.bom index 9fb2c58..1ab1bbb 100644 --- a/catalog/three-tier-webapp/three-tier-webapp.bom +++ b/catalog/three-tier-webapp/three-tier-webapp.bom @@ -69,6 +69,17 @@ brooklyn.catalog: enricher.targetSensor: $brooklyn:sensor("webapp.reqs.perSec.perNode") enricher.aggregating.fromMembers: true transformation: average + - type: org.apache.brooklyn.enricher.stock.Aggregator + brooklyn.config: + enricher.sourceSensor: $brooklyn:sensor("host.public.address") # not sure about this one + enricher.targetSensor: $brooklyn:sensor("addr.list") + enricher.aggregating.fromMembers: true + - type: org.apache.brooklyn.enricher.stock.Joiner + brooklyn.config: + enricher.joiner.minimum: $brooklyn:config("cluster.initial.size") + enricher.sourceSensor: $brooklyn:sensor("addr.list") + enricher.targetSensor: $brooklyn:sensor("addr.list.string") + enricher.joiner.separator: "," brooklyn.policies: - type: org.apache.brooklyn.policy.ha.ServiceReplacer - type: org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy @@ -86,6 +97,7 @@ brooklyn.catalog: brooklyn.config: app.port: 8080 #loadbalancer.serverpool: $brooklyn:entity("cluster") + server.list: $brooklyn:entity("cluster").attributeWhenReady("addr.list.string") nginx.sticky: false #ssl: $brooklyn:config("ssl") - type: org.apache.brooklyn.entity.database.mysql5