This repository was archived by the owner on Mar 11, 2025. It is now read-only.
File tree 4 files changed +34
-6
lines changed
4 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ type Config struct {
14
14
}
15
15
16
16
type Observability struct {
17
- LogLevel string `default:"debug" split_words:"true"`
18
- LogFile string `default:"out.log" split_words:"true"`
17
+ LogLevel string `default:"debug" split_words:"true"`
18
+ LogFile string `default:"out.log" split_words:"true"`
19
+ HealthPort uint16 `default:"9001" split_words:"true"`
19
20
}
20
21
21
22
type Prover struct {
Original file line number Diff line number Diff line change @@ -41,8 +41,9 @@ func (s *ConfigTestSuite) Test_LoadConfig_DefaultValues() {
41
41
s .Nil (err )
42
42
s .Equal (c , & config.Config {
43
43
Observability : & config.Observability {
44
- LogLevel : "debug" ,
45
- LogFile : "out.log" ,
44
+ LogLevel : "debug" ,
45
+ LogFile : "out.log" ,
46
+ HealthPort : 9001 ,
46
47
},
47
48
Prover : & config.Prover {
48
49
URL : "http://prover.com" ,
@@ -54,6 +55,7 @@ func (s *ConfigTestSuite) Test_LoadConfig_DefaultValues() {
54
55
func (s * ConfigTestSuite ) Test_LoadEVMConfig_SuccessfulLoad () {
55
56
os .Setenv ("SPECTRE_OBSERVABILITY_LOG_LEVEL" , "info" )
56
57
os .Setenv ("SPECTRE_OBSERVABILITY_LOG_FILE" , "out2.log" )
58
+ os .Setenv ("SPECTRE_OBSERVABILITY_HEALTH_PORT" , "9003" )
57
59
os .Setenv ("SPECTRE_PROVER_URL" , "http://prover.com" )
58
60
os .Setenv ("SPECTRE_DOMAINS" , "1:evm,2:evm" )
59
61
@@ -65,8 +67,9 @@ func (s *ConfigTestSuite) Test_LoadEVMConfig_SuccessfulLoad() {
65
67
s .Nil (err )
66
68
s .Equal (c , & config.Config {
67
69
Observability : & config.Observability {
68
- LogLevel : "info" ,
69
- LogFile : "out2.log" ,
70
+ LogLevel : "info" ,
71
+ LogFile : "out2.log" ,
72
+ HealthPort : 9003 ,
70
73
},
71
74
Prover : & config.Prover {
72
75
URL : "http://prover.com" ,
Original file line number Diff line number Diff line change
1
+ // The Licensed Work is (c) 2023 Sygma
2
+ // SPDX-License-Identifier: LGPL-3.0-only
3
+
4
+ package health
5
+
6
+ import (
7
+ "fmt"
8
+ "net/http"
9
+
10
+ "github.com/rs/zerolog/log"
11
+ )
12
+
13
+ // StartHealthEndpoint starts /health endpoint on provided port that returns ok on invocation
14
+ func StartHealthEndpoint (port uint16 ) {
15
+ http .HandleFunc ("/health" , func (w http.ResponseWriter , r * http.Request ) {
16
+ _ , _ = w .Write ([]byte ("ok" ))
17
+ })
18
+
19
+ _ = http .ListenAndServe (fmt .Sprintf (":%d" , port ), nil )
20
+ log .Info ().Msgf ("started /health endpoint on port %d" , port )
21
+ }
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import (
25
25
evmMessage "github.com/sygmaprotocol/spectre-node/chains/evm/message"
26
26
"github.com/sygmaprotocol/spectre-node/chains/evm/prover"
27
27
"github.com/sygmaprotocol/spectre-node/config"
28
+ "github.com/sygmaprotocol/spectre-node/health"
28
29
"github.com/sygmaprotocol/sygma-core/chains/evm"
29
30
"github.com/sygmaprotocol/sygma-core/chains/evm/client"
30
31
"github.com/sygmaprotocol/sygma-core/chains/evm/transactor/gas"
@@ -51,6 +52,8 @@ func main() {
51
52
52
53
log .Info ().Msg ("Loaded configuration" )
53
54
55
+ go health .StartHealthEndpoint (cfg .Observability .HealthPort )
56
+
54
57
domains := make ([]uint8 , 0 )
55
58
for domain := range cfg .Domains {
56
59
domains = append (domains , domain )
You can’t perform that action at this time.
0 commit comments