From 1c1322e3d2a220af47ef9ead8091d133905e6bad Mon Sep 17 00:00:00 2001 From: Xinwei Xiong <3293172751@qq.com> Date: Tue, 5 Dec 2023 16:12:00 +0800 Subject: [PATCH] feat: Enhance Template Generation Logic in OPENIM Deployment Scripts (#1510) * feat: add init-config.sh * feat: add helm charts test cicd Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add helm charts test cicd Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add helm charts test cicd Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: add helm charts test cicd Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --- .github/workflows/openimci.yml | 1 - config/prometheus.yml | 85 ---------------------------------- scripts/init-config.sh | 12 +++++ 3 files changed, 12 insertions(+), 86 deletions(-) delete mode 100644 config/prometheus.yml diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml index 707369379..5f010db8a 100644 --- a/.github/workflows/openimci.yml +++ b/.github/workflows/openimci.yml @@ -127,7 +127,6 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Run OpenIM make install start run: | - sudo make init && \ sudo make install execute-scripts: diff --git a/config/prometheus.yml b/config/prometheus.yml deleted file mode 100644 index 7950c5d33..000000000 --- a/config/prometheus.yml +++ /dev/null @@ -1,85 +0,0 @@ -# my global config -global: - scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. - evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. - # scrape_timeout is set to the global default (10s). - -# Alertmanager configuration -alerting: - alertmanagers: - - static_configs: - - targets: ['172.28.0.1:19093'] - -# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. -rule_files: - - "instance-down-rules.yml" -# - "first_rules.yml" -# - "second_rules.yml" - -# A scrape configuration containing exactly one endpoint to scrape: -# Here it's Prometheus itself. -scrape_configs: - # The job name is added as a label "job='job_name'"" to any timeseries scraped from this config. - # Monitored information captured by prometheus - - job_name: 'node-exporter' - static_configs: - - targets: [ '172.28.0.1:19100' ] - labels: - namespace: 'default' - - # prometheus fetches application services - - job_name: 'openimserver-openim-api' - static_configs: - - targets: [ '172.28.0.1:20100' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-msggateway' - static_configs: - - targets: [ '172.28.0.1:20140' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-msgtransfer' - static_configs: - - targets: [ 172.28.0.1:21400, 172.28.0.1:21401, 172.28.0.1:21402, 172.28.0.1:21403 ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-push' - static_configs: - - targets: [ '172.28.0.1:20170' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-rpc-auth' - static_configs: - - targets: [ '172.28.0.1:20160' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-rpc-conversation' - static_configs: - - targets: [ '172.28.0.1:20230' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-rpc-friend' - static_configs: - - targets: [ '172.28.0.1:20120' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-rpc-group' - static_configs: - - targets: [ '172.28.0.1:20150' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-rpc-msg' - static_configs: - - targets: [ '172.28.0.1:20130' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-rpc-third' - static_configs: - - targets: [ '172.28.0.1:21301' ] - labels: - namespace: 'default' - - job_name: 'openimserver-openim-rpc-user' - static_configs: - - targets: [ '172.28.0.1:20110' ] - labels: - namespace: 'default' diff --git a/scripts/init-config.sh b/scripts/init-config.sh index a4672c62d..3fcd2fdfd 100755 --- a/scripts/init-config.sh +++ b/scripts/init-config.sh @@ -35,6 +35,8 @@ declare -A TEMPLATES=( ["${OPENIM_ROOT}/deployments/templates/alertmanager.yml"]="${OPENIM_ROOT}/config/alertmanager.yml" ) +openim::log::info "Read more configuration information: https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/environment.md" + for template in "${!TEMPLATES[@]}"; do if [[ ! -f "${template}" ]]; then openim::log::error_exit "template file ${template} does not exist..." @@ -42,6 +44,16 @@ for template in "${!TEMPLATES[@]}"; do IFS=';' read -ra OUTPUT_FILES <<< "${TEMPLATES[$template]}" for output_file in "${OUTPUT_FILES[@]}"; do + if [[ -f "${output_file}" ]]; then + read -p "File ${output_file} already exists. Overwrite? (Y/N): " + if [[ $REPLY =~ ^[Yy]$ ]]; then + openim::log::info "Overwriting ${output_file}. Previous configuration will be lost." + else + openim::log::info "Skipping generation of ${output_file}." + continue + fi + fi + openim::log::info "⌚ Working with template file: ${template} to ${output_file}..." "${OPENIM_ROOT}/scripts/genconfig.sh" "${ENV_FILE}" "${template}" > "${output_file}" || { openim::log::error "Error processing template file ${template}"