File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,6 +43,19 @@ task bootstrap(type: Exec, dependsOn: ['cloneSqlCli']) {
4343
4444}
4545
46+ def isPrometheusRunning = { ->
47+ try {
48+ def process = " pgrep -f prometheus" . execute()
49+ def output = process. text
50+ def result = ! output. trim(). isEmpty()
51+ println " Prometheus running status: ${ result} "
52+ return result
53+ } catch (Exception e) {
54+ println " Error checking Prometheus process: ${ e.message} "
55+ return false
56+ }
57+ }
58+
4659task startPrometheus (type : SpawnProcessTask ) {
4760 doFirst {
4861 download. run {
@@ -63,7 +76,7 @@ task startPrometheus(type: SpawnProcessTask) {
6376 command " $projectDir /bin/prometheus/prometheus --storage.tsdb.path=$projectDir /bin/prometheus/data --config.file=$projectDir /bin/prometheus/prometheus.yml"
6477 ready ' TSDB started'
6578 pidLockFileName " .prom.pid.lock"
66- onlyIf { ! ignorePrometheus && getOSFamilyType() != " windows" }
79+ onlyIf { ! ignorePrometheus && getOSFamilyType() != " windows" && ! isPrometheusRunning() }
6780}
6881
6982// evaluationDependsOn(':')
Original file line number Diff line number Diff line change @@ -295,6 +295,19 @@ testClusters {
295295 }
296296}
297297
298+ def isPrometheusRunning () {
299+ try {
300+ def process = " pgrep -f prometheus" . execute()
301+ def output = process. text
302+ def result = ! output. trim(). isEmpty()
303+ println " Prometheus running status: ${ result} "
304+ return result
305+ } catch (Exception e) {
306+ println " Error checking Prometheus process: ${ e.message} "
307+ return false
308+ }
309+ }
310+
298311task startPrometheus (type : SpawnProcessTask ) {
299312 mustRunAfter ' :doctest:doctest'
300313
@@ -319,7 +332,7 @@ task startPrometheus(type: SpawnProcessTask) {
319332 }
320333 command " $projectDir /bin/prometheus/prometheus --storage.tsdb.path=$projectDir /bin/prometheus/data --config.file=$projectDir /bin/prometheus/prometheus.yml"
321334 ready ' TSDB started'
322- onlyIf { ! ignorePrometheus }
335+ onlyIf { ! ignorePrometheus && ! isPrometheusRunning() }
323336}
324337
325338task stopPrometheus (type : KillProcessTask ) {
You can’t perform that action at this time.
0 commit comments