#!/bin/bash
set -e
ulimit -n 1000000

# WARNING: This file was auto-generated. Do not edit!
#          All your edit might be overwritten!

{% set all_pd = [] -%}
{% set pd_hosts = groups.pd_servers %}
{% for host in pd_hosts -%}
  {% set pd_ip = hostvars[host].ansible_host | default(hostvars[host].inventory_hostname) -%}
  {% set pd_port = hostvars[host].pd_client_port -%}
  {% set _ = all_pd.append("http://%s:%s" % (pd_ip, pd_port)) -%}
{% endfor -%}

{% set all_tidb = [] -%}
{% set tidb_hosts = groups.tidb_servers %}
{% for host in tidb_hosts -%}
  {% set tidb_ip = hostvars[host].ansible_host | default(hostvars[host].inventory_hostname) -%}
  {% set tidb_status_port = hostvars[host].tidb_status_port -%}
  {% set _ = all_tidb.append("http://%s:%s" % (tidb_ip, tidb_status_port)) -%}
{% endfor -%}

exec > >(tee -i -a "{{ dashboard_log_dir }}/{{ dashboard_log_filename }}")
exec 2>&1

exec /usr/bin/dashboard-ui \
    -pd-endpoints="{{ all_pd | join(',') }}" \
    -tidb-endpoints="{{ all_tidb | join(',') }}"
