@@ -20,12 +20,13 @@ package main
2020import (
2121 "flag"
2222 "fmt"
23- v1 "github.com/apache/doris-operator/api/doris/v1"
24- "github.com/apache/doris-operator/pkg/common/utils/resource"
25- "github.com/spf13/viper"
2623 "net/http"
2724 "os"
2825 "strconv"
26+
27+ v1 "github.com/apache/doris-operator/api/doris/v1"
28+ "github.com/apache/doris-operator/pkg/common/utils/resource"
29+ "github.com/spf13/viper"
2930)
3031
3132var (
@@ -40,7 +41,7 @@ func main() {
4041 return
4142 }
4243
43- fmt .Println ("start component " + componentType + "for debugging....." )
44+ fmt .Println ("start component " + componentType + " for debugging....." )
4445 listenPort := readConfigListenPort ()
4546 //registerMockApiHealth()
4647 if err := http .ListenAndServe (":" + listenPort , nil ); err != nil {
@@ -62,7 +63,28 @@ func flagParse() {
6263}
6364
6465func readConfigListenPort () string {
65- configFileName := dorisRootPath + "/" + componentType + "/conf/" + componentType + ".conf"
66+
67+ var listenPortName string
68+ var configFileName string
69+ var listenPort string
70+
71+ switch componentType {
72+ case "fe" :
73+ configFileName = dorisRootPath + "/fe/conf/fe.conf"
74+ listenPortName = resource .QUERY_PORT
75+ case "be" :
76+ configFileName = dorisRootPath + "/be/conf/be.conf"
77+ listenPortName = resource .HEARTBEAT_SERVICE_PORT
78+ case "ms" :
79+ configFileName = dorisRootPath + "/ms/conf/doris_cloud.conf"
80+ listenPortName = resource .BRPC_LISTEN_PORT
81+ default :
82+ {
83+ fmt .Println ("the componentType is not supported:" + componentType )
84+ os .Exit (1 )
85+ }
86+ }
87+
6688 _ , err := os .Stat (configFileName )
6789 if err != nil {
6890 fmt .Println ("the config file is not exist, stat error" , err .Error ())
@@ -72,34 +94,15 @@ func readConfigListenPort() string {
7294 file , _ := os .Open (configFileName )
7395 viper .SetConfigType ("properties" )
7496 viper .ReadConfig (file )
75-
76- var listenPort string
77- if componentType == "fe" {
78- configQueryPort := viper .GetString (resource .QUERY_PORT )
79- if configQueryPort == "" {
80- listenPort = strconv .Itoa (int (resource .GetDefaultPort (resource .QUERY_PORT )))
81- }
82- } else if componentType == "be" {
83- configHeartbeatPort := viper .GetString (resource .HEARTBEAT_SERVICE_PORT )
84- fmt .Println ("component be" + configHeartbeatPort )
85- if configHeartbeatPort == "" {
86- listenPort = strconv .Itoa (int (resource .GetDefaultPort (resource .HEARTBEAT_SERVICE_PORT )))
87- }
97+ listenPort = viper .GetString (listenPortName )
98+ if listenPort == "" {
99+ listenPort = strconv .Itoa (int (resource .GetDefaultPort (listenPortName )))
88100 }
89- fmt .Println ("component listen port " + listenPort )
90101
102+ fmt .Println ("component listen port " + listenPort )
91103 return listenPort
92104}
93105
94- func registerMockApiHealth () {
95- if componentType == "fe" {
96- http .HandleFunc ("/api/health" , mockFEHealth )
97- return
98- }
99-
100- http .HandleFunc ("/api/health" , mockBEHealth )
101- }
102-
103106func kickOffDebug () bool {
104107 annotationFileName := resource .POD_INFO_PATH + "/annotations"
105108 if _ , err := os .Stat (annotationFileName ); os .IsNotExist (err ) {
@@ -123,14 +126,23 @@ func kickOffDebug() bool {
123126
124127 valueDoris := viper .GetString (v1 .AnnotationDebugDorisKey )
125128
126- if valueDoris == "\" " + v1 .AnnotationDebugDorisKey + "\" " {
129+ if valueDoris == "\" " + v1 .AnnotationDebugValue + "\" " {
127130 return true
128131 }
129132
130- fmt .Println ( "the value not equal!" , value , v1 .AnnotationDebugValue , v1 .AnnotationDebugDorisKey )
133+ fmt .Printf ( "No debug flag matched, flags: [%s:%s],[%s:%s] !" , v1 .AnnotationDebugDorisKey , valueDoris , v1 .AnnotationDebugKey , value )
131134 return false
132135}
133136
137+ func registerMockApiHealth () {
138+ if componentType == "fe" {
139+ http .HandleFunc ("/api/health" , mockFEHealth )
140+ return
141+ }
142+
143+ http .HandleFunc ("/api/health" , mockBEHealth )
144+ }
145+
134146func mockFEHealth (w http.ResponseWriter , r * http.Request ) {
135147 //{"msg":"success","code":0,"data":{"online_backend_num":3,"total_backend_num":3},"count":0}
136148 w .WriteHeader (http .StatusOK )
0 commit comments