github.com/pingcap/tiup@v1.15.1/components/playground/instance/tiflash_pre7_proxy_config.go (about)

     1  // Copyright 2020 PingCAP, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package instance
    15  
    16  import (
    17  	"fmt"
    18  	"io"
    19  
    20  	"github.com/pingcap/tiup/pkg/tidbver"
    21  	"github.com/pingcap/tiup/pkg/utils"
    22  )
    23  
    24  const tiflashProxyConfigOld = `
    25  log-file = "%[1]s/tiflash_tikv.log"
    26  
    27  [rocksdb]
    28  wal-dir = ""
    29  max-open-files = 256
    30  
    31  [security]
    32  ca-path = ""
    33  cert-path = ""
    34  key-path = ""
    35  
    36  [server]
    37  addr = "0.0.0.0:%[4]d"
    38  advertise-addr = "%[2]s:%[4]d"
    39  engine-addr = "%[2]s:%[3]d"
    40  %[5]s
    41  
    42  [storage]
    43  data-dir = "%[6]s"
    44  
    45  [raftdb]
    46  max-open-files = 256
    47  `
    48  
    49  // writeTiFlashProxyConfigOld is for < 7.1.0. Not maintained any more. Do not introduce new features.
    50  func writeTiFlashProxyConfigOld(w io.Writer, version utils.Version, host, deployDir string, servicePort, proxyPort, proxyStatusPort int) error {
    51  	// TODO: support multi-dir
    52  	dataDir := fmt.Sprintf("%s/flash", deployDir)
    53  	logDir := fmt.Sprintf("%s/log", deployDir)
    54  	ip := AdvertiseHost(host)
    55  	var statusAddr string
    56  	if tidbver.TiFlashSupportAdvertiseStatusAddr(version.String()) {
    57  		statusAddr = fmt.Sprintf(`status-addr = "0.0.0.0:%[2]d"
    58  advertise-status-addr = "%[1]s:%[2]d"`, ip, proxyStatusPort)
    59  	} else {
    60  		statusAddr = fmt.Sprintf(`status-addr = "%[1]s:%[2]d"`, ip, proxyStatusPort)
    61  	}
    62  	conf := fmt.Sprintf(tiflashProxyConfigOld, logDir, ip, servicePort, proxyPort, statusAddr, dataDir)
    63  	_, err := w.Write([]byte(conf))
    64  	return err
    65  }