diff --git a/client-registry-jempi/docker-compose.api-dev.yml b/client-registry-jempi/docker-compose.api-dev.yml new file mode 100644 index 00000000..9fdd32ca --- /dev/null +++ b/client-registry-jempi/docker-compose.api-dev.yml @@ -0,0 +1,9 @@ +version: '3.9' + +services: + jempi-api: + ports: + - published: 50000 + target: 50000 + protocol: tcp + mode: host diff --git a/client-registry-jempi/docker-compose.api.yml b/client-registry-jempi/docker-compose.api.yml new file mode 100644 index 00000000..9e33e217 --- /dev/null +++ b/client-registry-jempi/docker-compose.api.yml @@ -0,0 +1,12 @@ +version: '3.9' + +services: + jempi-api: + image: jembi/jempi-api:${JEMPI_API_IMAGE_TAG} + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_API_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_API_MEMORY_RESERVE} diff --git a/client-registry-jempi/docker-compose.combined-dev.yml b/client-registry-jempi/docker-compose.combined-dev.yml new file mode 100644 index 00000000..a154d235 --- /dev/null +++ b/client-registry-jempi/docker-compose.combined-dev.yml @@ -0,0 +1,23 @@ +version: '3.9' + +services: + jempi-sync-receiver: + ports: + - published: 50040 + target: 50000 + protocol: tcp + mode: host + + jempi-controller: + ports: + - published: 50020 + target: 50000 + protocol: tcp + mode: host + + jempi-linker: + ports: + - published: 50010 + target: 50000 + protocol: tcp + mode: host diff --git a/client-registry-jempi/docker-compose.combined.yml b/client-registry-jempi/docker-compose.combined.yml new file mode 100644 index 00000000..445965c1 --- /dev/null +++ b/client-registry-jempi/docker-compose.combined.yml @@ -0,0 +1,62 @@ +version: '3.9' + +services: + jempi-async-receiver: + image: jembi/jempi-async-receiver:${JEMPI_AJEMPI_SYNC_RECEIVER_IMAGE_TAG} + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_ASYNC_RECEIVER_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_ASYNC_RECEIVER_MEMORY_RESERVE} + + jempi-sync-receiver: + image: jembi/jempi-sync-receiver:${JEMPI_SYNC_RECEIVER_IMAGE_TAG} + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_SYNC_RECEIVER_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_SYNC_RECEIVER_MEMORY_RESERVE} + + jempi-pre-processor: + image: jembi/jempi-pre-processor:${JEMPI_PRE_PROCESSOR_IMAGE_TAG} + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_PRE_PROCESSOR_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_PRE_PROCESSOR_MEMORY_RESERVE} + + jempi-controller: + image: jembi/jempi-controller:${JEMPI_CONTROLLER_IMAGE_TAG} + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_CONTROLLER_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_CONTROLLER_MEMORY_RESERVE} + + jempi-em-calculator: + image: jembi/jempi-em-calculator:${JEMPI_EM_CALCULATOR_IMAGE_TAG} + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_EM_CALCULATOR_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_EM_CALCULATOR_MEMORY_RESERVE} + + jempi-linker: + image: jembi/jempi-linker:${JEMPI_LINKER_IMAGE_TAG} + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_LINKER_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_LINKER_MEMORY_RESERVE} diff --git a/client-registry-jempi/docker-compose.dgraph-cluster.yml b/client-registry-jempi/docker-compose.dgraph-cluster.yml index 32c9da6b..86898a77 100644 --- a/client-registry-jempi/docker-compose.dgraph-cluster.yml +++ b/client-registry-jempi/docker-compose.dgraph-cluster.yml @@ -1,12 +1,6 @@ version: '3.9' services: - jempi-zero-01: - deploy: - placement: - constraints: - - node.hostname == node-1 - jempi-alpha-01: deploy: placement: diff --git a/client-registry-jempi/docker-compose.dgraph-dev.yml b/client-registry-jempi/docker-compose.dgraph-dev.yml index 054675ee..51be6bac 100644 --- a/client-registry-jempi/docker-compose.dgraph-dev.yml +++ b/client-registry-jempi/docker-compose.dgraph-dev.yml @@ -1,17 +1,6 @@ version: '3.9' services: - jempi-zero-01: - ports: - - published: 5080 - target: 5080 - protocol: tcp - mode: host - - published: 6080 - target: 6080 - protocol: tcp - mode: host - jempi-alpha-01: ports: - published: 8070 @@ -45,7 +34,7 @@ services: protocol: tcp mode: host - ratel: + jempi-ratel: ports: - published: 8010 target: 8000 diff --git a/client-registry-jempi/docker-compose.dgraph-zero-cluster.yml b/client-registry-jempi/docker-compose.dgraph-zero-cluster.yml new file mode 100644 index 00000000..ca029604 --- /dev/null +++ b/client-registry-jempi/docker-compose.dgraph-zero-cluster.yml @@ -0,0 +1,8 @@ +version: '3.9' + +services: + jempi-zero-01: + deploy: + placement: + constraints: + - node.hostname == node-1 diff --git a/client-registry-jempi/docker-compose.dgraph-zero-dev.yml b/client-registry-jempi/docker-compose.dgraph-zero-dev.yml new file mode 100644 index 00000000..43f49501 --- /dev/null +++ b/client-registry-jempi/docker-compose.dgraph-zero-dev.yml @@ -0,0 +1,13 @@ +version: '3.9' + +services: + jempi-zero-01: + ports: + - published: 5080 + target: 5080 + protocol: tcp + mode: host + - published: 6080 + target: 6080 + protocol: tcp + mode: host diff --git a/client-registry-jempi/docker-compose.dgraph-zero.yml b/client-registry-jempi/docker-compose.dgraph-zero.yml new file mode 100644 index 00000000..4739a3ba --- /dev/null +++ b/client-registry-jempi/docker-compose.dgraph-zero.yml @@ -0,0 +1,22 @@ +version: '3.9' + +services: + jempi-zero-01: + image: dgraph/dgraph:v22.0.0 + volumes: + - jempi-zero-01-data:/dgraph + deploy: + replicas: 1 + resources: + limits: + memory: ${JEMPI_ZERO_01_MEMORY_LIMIT} + reservations: + memory: ${JEMPI_ZERO_01_MEMORY_RESERVE} + restart_policy: + condition: on-failure + command: dgraph zero --my=jempi-zero-01:5080 --replicas 1 + +volumes: + jempi-zero-01-data: + + diff --git a/client-registry-jempi/docker-compose.dgraph.yml b/client-registry-jempi/docker-compose.dgraph.yml index 048c6563..6ca9d097 100644 --- a/client-registry-jempi/docker-compose.dgraph.yml +++ b/client-registry-jempi/docker-compose.dgraph.yml @@ -1,21 +1,6 @@ version: '3.9' services: - jempi-zero-01: - image: dgraph/dgraph:v22.0.0 - volumes: - - jempi-zero-01-data:/dgraph - deploy: - replicas: 1 - resources: - limits: - memory: ${ZERO_01_MEMORY_LIMIT} - reservations: - memory: ${ZERO_01_MEMORY_RESERVE} - restart_policy: - condition: on-failure - command: dgraph zero --my=jempi-zero-01:5080 --replicas 1 - jempi-alpha-01: image: dgraph/dgraph:v22.0.0 volumes: @@ -24,9 +9,9 @@ services: replicas: 1 resources: limits: - memory: ${ALPHA_01_MEMORY_LIMIT} + memory: ${JEMPI_ALPHA_01_MEMORY_LIMIT} reservations: - memory: ${ALPHA_01_MEMORY_RESERVE} + memory: ${JEMPI_ALPHA_01_MEMORY_RESERVE} restart_policy: condition: on-failure command: dgraph alpha --my=jempi-alpha-01:7080 --zero=jempi-zero-01:5080 --security whitelist=0.0.0.0/0 --telemetry "sentry=false;" @@ -39,9 +24,9 @@ services: replicas: 1 resources: limits: - memory: ${ALPHA_02_MEMORY_LIMIT} + memory: ${JEMPI_ALPHA_02_MEMORY_LIMIT} reservations: - memory: ${ALPHA_02_MEMORY_RESERVE} + memory: ${JEMPI_ALPHA_02_MEMORY_RESERVE} restart_policy: condition: on-failure command: dgraph alpha --my=jempi-alpha-02:7081 --zero=jempi-zero-01:5080 --security whitelist=0.0.0.0/0 -o 1 --telemetry "sentry=false;" @@ -54,9 +39,9 @@ services: replicas: 1 resources: limits: - memory: ${ALPHA_03_MEMORY_LIMIT} + memory: ${JEMPI_ALPHA_03_MEMORY_LIMIT} reservations: - memory: ${ALPHA_03_MEMORY_RESERVE} + memory: ${JEMPI_ALPHA_03_MEMORY_RESERVE} restart_policy: condition: on-failure command: dgraph alpha --my=jempi-alpha-03:7082 --zero=jempi-zero-01:5080 --security whitelist=0.0.0.0/0 -o 2 --telemetry "sentry=false;" @@ -67,15 +52,14 @@ services: replicas: 1 resources: limits: - memory: ${RATEL_MEMORY_LIMIT} + memory: ${JEMPI_RATEL_MEMORY_LIMIT} reservations: - memory: ${RATEL_MEMORY_RESERVE} + memory: ${JEMPI_RATEL_MEMORY_RESERVE} restart_policy: condition: on-failure command: dgraph-ratel volumes: - jempi-zero-01-data: jempi-alpha-01-data: jempi-alpha-02-data: jempi-alpha-03-data: diff --git a/client-registry-jempi/docker-compose.kafka.yml b/client-registry-jempi/docker-compose.kafka.yml index 787d71d4..f1ca8726 100644 --- a/client-registry-jempi/docker-compose.kafka.yml +++ b/client-registry-jempi/docker-compose.kafka.yml @@ -23,9 +23,9 @@ services: replicas: 1 resources: limits: - memory: ${KAFKA_01_MEMORY_LIMIT} + memory: ${JEMPI_KAFKA_01_MEMORY_LIMIT} reservations: - memory: ${KAFKA_01_MEMORY_RESERVE} + memory: ${JEMPI_KAFKA_01_MEMORY_RESERVE} restart_policy: condition: on-failure @@ -51,9 +51,9 @@ services: replicas: 1 resources: limits: - memory: ${KAFKA_02_MEMORY_LIMIT} + memory: ${JEMPI_KAFKA_02_MEMORY_LIMIT} reservations: - memory: ${KAFKA_02_MEMORY_RESERVE} + memory: ${JEMPI_KAFKA_02_MEMORY_RESERVE} restart_policy: condition: on-failure @@ -79,9 +79,9 @@ services: replicas: 1 resources: limits: - memory: ${KAFKA_03_MEMORY_LIMIT} + memory: ${JEMPI_KAFKA_03_MEMORY_LIMIT} reservations: - memory: ${KAFKA_03_MEMORY_RESERVE} + memory: ${JEMPI_KAFKA_03_MEMORY_RESERVE} restart_policy: condition: on-failure diff --git a/client-registry-jempi/package-metadata.json b/client-registry-jempi/package-metadata.json index 9e7a1854..67cb5994 100644 --- a/client-registry-jempi/package-metadata.json +++ b/client-registry-jempi/package-metadata.json @@ -7,27 +7,48 @@ "dependencies": [], "environmentVariables": { "STATEFUL_NODES": "single", - "KAFKA_01_MEMORY_LIMIT": "3G", - "KAFKA_01_MEMORY_RESERVE": "500M", - "KAFKA_02_MEMORY_LIMIT": "3G", - "KAFKA_02_MEMORY_RESERVE": "500M", - "KAFKA_03_MEMORY_LIMIT": "3G", - "KAFKA_03_MEMORY_RESERVE": "500M", + "JEMPI_KAFKA_01_MEMORY_LIMIT": "3G", + "JEMPI_KAFKA_01_MEMORY_RESERVE": "500M", + "JEMPI_KAFKA_02_MEMORY_LIMIT": "3G", + "JEMPI_KAFKA_02_MEMORY_RESERVE": "500M", + "JEMPI_KAFKA_03_MEMORY_LIMIT": "3G", + "JEMPI_KAFKA_03_MEMORY_RESERVE": "500M", "JEMPI_KAFDROP_CPU_LIMIT": "0", "JEMPI_KAFDROP_CPU_RESERVE": "0.05", "JEMPI_KAFDROP_MEMORY_LIMIT": "3G", "JEMPI_KAFDROP_MEMORY_RESERVE": "500M", - "JEMPI_KAFKA_TOPICS": "jempi-patient-staging-01,jempi-patient-staging-02,jempi-patient-staging-disi,jempi-patient-controller,jempi-patient-em,jempi-patient-linker,jempi-mu-linker,jempi-journal,jempi-notifications", + "JEMPI_ZERO_01_MEMORY_LIMIT": "3G", + "JEMPI_ZERO_01_MEMORY_RESERVE": "500M", + "JEMPI_ALPHA_01_MEMORY_LIMIT": "3G", + "JEMPI_ALPHA_01_MEMORY_RESERVE": "500M", + "JEMPI_ALPHA_02_MEMORY_LIMIT": "3G", + "JEMPI_ALPHA_02_MEMORY_RESERVE": "500M", + "JEMPI_ALPHA_03_MEMORY_LIMIT": "3G", + "JEMPI_ALPHA_03_MEMORY_RESERVE": "500M", + "JEMPI_RATEL_MEMORY_LIMIT": "3G", + "JEMPI_RATEL_MEMORY_RESERVE": "500M", + "JEMPI_ASYNC_RECEIVER_MEMORY_LIMIT": "3G", + "JEMPI_ASYNC_RECEIVER_MEMORY_RESERVE": "500M", + "JEMPI_EM_CALCULATOR_MEMORY_LIMIT": "3G", + "JEMPI_EM_CALCULATOR_MEMORY_RESERVE": "500M", + "JEMPI_CONTROLLER_MEMORY_LIMIT": "3G", + "JEMPI_CONTROLLER_MEMORY_RESERVE": "500M", + "JEMPI_LINKER_MEMORY_LIMIT": "3G", + "JEMPI_LINKER_MEMORY_RESERVE": "500M", + "JEMPI_PRE_PROCESSOR_MEMORY_LIMIT": "3G", + "JEMPI_PRE_PROCESSOR_MEMORY_RESERVE": "500M", + "JEMPI_SYNC_RECEIVER_MEMORY_LIMIT": "3G", + "JEMPI_SYNC_RECEIVER_MEMORY_RESERVE": "500M", + "JEMPI_API_MEMORY_LIMIT": "3G", + "JEMPI_API_MEMORY_RESERVE": "500M", + "JEMPI_KAFKA_TOPICS": "JeMPI-async-preprocessor,JeMPI-patient-controller,JeMPI-patient-em,JeMPI-patient-linker,JeMPI-mu-linker,JeMPI-notifications", "JEMPI_KAFKA_DEBUG": false, - "ZERO_01_MEMORY_LIMIT": "3G", - "ZERO_01_MEMORY_RESERVE": "500M", - "ALPHA_01_MEMORY_LIMIT": "3G", - "ALPHA_01_MEMORY_RESERVE": "500M", - "ALPHA_02_MEMORY_LIMIT": "3G", - "ALPHA_02_MEMORY_RESERVE": "500M", - "ALPHA_03_MEMORY_LIMIT": "3G", - "ALPHA_03_MEMORY_RESERVE": "500M", - "RATEL_MEMORY_LIMIT": "3G", - "RATEL_MEMORY_RESERVE": "500M" + "JEMPI_AJEMPI_SYNC_RECEIVER_IMAGE_TAG": "0.1.0", + "JEMPI_SYNC_RECEIVER_IMAGE_TAG": "0.1.0", + "JEMPI_PRE_PROCESSOR_IMAGE_TAG": "0.1.0", + "JEMPI_CONTROLLER_IMAGE_TAG": "0.1.0", + "JEMPI_EM_CALCULATOR_IMAGE_TAG": "0.1.0", + "JEMPI_LINKER_IMAGE_TAG": "0.1.0", + "JEMPI_API_IMAGE_TAG": "0.1.0" } } diff --git a/client-registry-jempi/swarm.sh b/client-registry-jempi/swarm.sh index 703f22e0..6b301b1c 100644 --- a/client-registry-jempi/swarm.sh +++ b/client-registry-jempi/swarm.sh @@ -16,33 +16,61 @@ readonly ROOT_PATH . "${ROOT_PATH}/utils/docker-utils.sh" . "${ROOT_PATH}/utils/log.sh" +service_names=( + "jempi-kafka-01" + "jempi-kafka-02" + "jempi-kafka-03" + "jempi-kafdrop" + "jempi-zero-01" + "jempi-alpha-01" + "jempi-alpha-02" + "jempi-alpha-03" + "jempi-ratel" + "jempi-async-receiver" + "jempi-sync-receiver" + "jempi-pre-processor" + "jempi-controller" + "jempi-em-calculator" + "jempi-linker" + "jempi-api" +) +readonly service_names + main() { if [[ "$MODE" == "dev" ]]; then log info "Running Client Registry JeMPI package in DEV mode" kafdrop_dev_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.kafdrop-dev.yml" dgraph_dev_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.dgraph-dev.yml" + dgraph_zero_dev_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.dgraph-zero-dev.yml" + combined_dev_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.combined-dev.yml" + api_dev_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.api-dev.yml" else log info "Running Client Registry JeMPI package in PROD mode" kafdrop_dev_compose_param="" dgraph_dev_compose_param="" + dgraph_zero_dev_compose_param="" + combined_dev_compose_param="" + api_dev_compose_param="" fi if [[ "$STATEFUL_NODES" == "cluster" ]]; then log info "Running in clustered mode" dgraph_cluster_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.dgraph-cluster.yml" + dgraph_zero_cluster_compose_param="-c ${COMPOSE_FILE_PATH}/docker-compose.dgraph-zero-cluster.yml" else log info "Running in single-node mode" dgraph_cluster_compose_param="" + dgraph_zero_cluster_compose_param="" fi if [[ "${ACTION}" == "init" ]] || [[ "${ACTION}" == "up" ]]; then - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafka.yml instant" "Failed to deploy Client Registry - JeMPI" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafka.yml instant" "Failed to deploy Client Registry - JeMPI (kafka.yml)" docker::await_service_ready jempi-kafka-01 docker::await_service_ready jempi-kafka-02 docker::await_service_ready jempi-kafka-03 - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafdrop.yml $kafdrop_dev_compose_param instant" "Failed to deploy jempi-Kafdrop" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.kafdrop.yml $kafdrop_dev_compose_param instant" "Failed to deploy Client Registry - JeMPI (kafdrop.yml)" docker::await_service_ready jempi-kafdrop @@ -57,51 +85,44 @@ main() { config::remove_stale_service_configs "${COMPOSE_FILE_PATH}"/importer/docker-compose.config.yml "jempi-kafka" - try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph.yml $dgraph_dev_compose_param $dgraph_cluster_compose_param instant" "Failed to deploy Client Registry - JeMPI" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph-zero.yml $dgraph_zero_dev_compose_param $dgraph_zero_cluster_compose_param instant" "Failed to deploy Client Registry - JeMPI (dgraph-zero.yml)" docker::await_service_ready jempi-zero-01 + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.dgraph.yml $dgraph_dev_compose_param $dgraph_cluster_compose_param instant" "Failed to deploy Client Registry - JeMPI (dgraph.yml)" + docker::await_service_ready jempi-alpha-01 docker::await_service_ready jempi-alpha-02 docker::await_service_ready jempi-alpha-03 docker::await_service_ready jempi-ratel - docker::deploy_sanity "jempi-kafka-01" "jempi-kafka-02" "jempi-kafka-03" "jempi-kafdrop" "jempi-zero-01" "jempi-alpha-01" "jempi-alpha-02" "jempi-alpha-03" "jempi-ratel" - elif [[ "${ACTION}" == "down" ]]; then - log info "Scaling down client-registry-jempi" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.combined.yml $combined_dev_compose_param instant" "Failed to deploy Client Registry - JeMPI (combined.yml)" - try "docker service scale instant_jempi-kafka-01=0" "Failed to scale down jempi-kafka-01" - try "docker service scale instant_jempi-kafka-02=0" "Failed to scale down jempi-kafka-02" - try "docker service scale instant_jempi-kafka-03=0" "Failed to scale down jempi-kafka-03" + docker::await_service_ready jempi-async-receiver + docker::await_service_ready jempi-sync-receiver + docker::await_service_ready jempi-pre-processor + docker::await_service_ready jempi-controller + docker::await_service_ready jempi-em-calculator + docker::await_service_ready jempi-linker - try "docker service scale instant_jempi-kafdrop=0" "Failed to scale down jempi-kafdrop" + try "docker stack deploy -c ${COMPOSE_FILE_PATH}/docker-compose.api.yml $api_dev_compose_param instant" "Failed to deploy Client Registry - JeMPI (api.yml)" - try "docker service scale instant_jempi-zero-01=0" "Failed to scale down jempi-zero-01" + docker::await_service_ready jempi-api - try "docker service scale instant_jempi-alpha-01=0" "Failed to scale down jempi-alpha-01" - try "docker service scale instant_jempi-alpha-02=0" "Failed to scale down jempi-alpha-02" - try "docker service scale instant_jempi-alpha-03=0" "Failed to scale down jempi-alpha-03" + docker::deploy_sanity "${service_names[@]}" + elif [[ "${ACTION}" == "down" ]]; then + log info "Scaling down client-registry-jempi" - try "docker service scale instant_jempi-ratel=0" "Failed to scale down jempi-ratel" + for service_name in "${service_names[@]}"; do + try "docker service scale instant_$service_name=0" "Failed to scale down $service_name" + done elif [[ "${ACTION}" == "destroy" ]]; then log warn "Volumes are only deleted on the host on which the command is run. Volumes on other nodes are not deleted" - docker::service_destroy jempi-kafka-01 - docker::service_destroy jempi-kafka-02 - docker::service_destroy jempi-kafka-03 - - docker::service_destroy jempi-kafdrop - - docker::service_destroy jempi-kafka-config-importer - - docker::service_destroy jempi-zero-01 - - docker::service_destroy jempi-alpha-01 - docker::service_destroy jempi-alpha-02 - docker::service_destroy jempi-alpha-03 - - docker::service_destroy jempi-ratel + for service_name in "${service_names[@]}"; do + docker::service_destroy "$service_name" + done docker::try_remove_volume jempi-kafka-01-data docker::try_remove_volume jempi-kafka-02-data diff --git a/config.yml b/config.yml index d4341dd3..5f5504ca 100644 --- a/config.yml +++ b/config.yml @@ -40,3 +40,5 @@ packages: name: Monitoring package - id: mpi-mediator name: OpenHIM-Sante Mediator + - id: client-registry-jempi + name: Client Registry - JeMPI