@@ -37,6 +37,9 @@ type Config struct {
37
37
CSRFSecretPath string
38
38
SessionSecretPath string
39
39
SessionsDirectory string
40
+ HealthcheckURL string
41
+ HealthcheckInterval time.Duration
42
+ HealthcheckStartup bool
40
43
HTTPDisable bool
41
44
HTTPAddress string
42
45
HTTPPort uint16
@@ -61,6 +64,9 @@ type Raw struct {
61
64
RetentionEnvelopeCount string `koanf:"retention.envelope_count"`
62
65
RetentionEnvelopeAge string `koanf:"retention.envelope_age"`
63
66
RetentionAttachmentSize string `koanf:"retention.attachment_size"`
67
+ HealthcheckURL string `koanf:"healthcheck.url"`
68
+ HealthcheckInterval string `koanf:"healthcheck.interval"`
69
+ HealthcheckStartup bool `koanf:"healthcheck.startup"`
64
70
SMTPDisable bool `koanf:"smtp.disable"`
65
71
SMTPHost string `koanf:"smtp.host"`
66
72
SMTPPort uint16 `koanf:"smtp.port"`
@@ -97,21 +103,23 @@ type RawRule struct {
97
103
}
98
104
99
105
var RawDefault = struct {
100
- TimeFormat string `koanf:"time_format"`
101
- MaxPayloadSize string `koanf:"max_payload_size"`
102
- DataDirectory string `koanf:"data_directory"`
103
- PythonExecutable string `koanf:"python_executable"`
104
- SMTPPort uint16 `koanf:"smtp.port"`
105
- SMTPMaxPayloadSize string `koanf:"smtp.max_payload_size"`
106
- HTTPPort uint16 `koanf:"http.port"`
106
+ HealthcheckInterval string `koanf:"healthcheck.interval"`
107
+ TimeFormat string `koanf:"time_format"`
108
+ MaxPayloadSize string `koanf:"max_payload_size"`
109
+ DataDirectory string `koanf:"data_directory"`
110
+ PythonExecutable string `koanf:"python_executable"`
111
+ SMTPPort uint16 `koanf:"smtp.port"`
112
+ SMTPMaxPayloadSize string `koanf:"smtp.max_payload_size"`
113
+ HTTPPort uint16 `koanf:"http.port"`
107
114
// IMAPPort uint16 `koanf:"imap.port"`
108
115
}{
109
- TimeFormat : timeFormat12H ,
110
- SMTPMaxPayloadSize : "25 MB" ,
111
- DataDirectory : "smtpbridge_data" ,
112
- PythonExecutable : "python3" ,
113
- SMTPPort : 1025 ,
114
- HTTPPort : 8080 ,
116
+ HealthcheckInterval : "5m" ,
117
+ TimeFormat : timeFormat12H ,
118
+ SMTPMaxPayloadSize : "25 MB" ,
119
+ DataDirectory : "smtpbridge_data" ,
120
+ PythonExecutable : "python3" ,
121
+ SMTPPort : 1025 ,
122
+ HTTPPort : 8080 ,
115
123
// IMAPPort: 10143,
116
124
}
117
125
@@ -130,6 +138,10 @@ func WithFlagSet(flags *flag.FlagSet) *flag.FlagSet {
130
138
flags .String ("python-executable" , "" , flagUsageString (RawDefault .PythonExecutable , "Python executable." ))
131
139
flags .Bool ("debug" , false , flagUsageBool (false , "Run in debug mode." ))
132
140
141
+ flags .String ("healthcheck-url" , "" , flagUsageString ("" , "Healthcheck URL to fetch." ))
142
+ flags .String ("healthcheck-interval" , "" , flagUsageString (RawDefault .HealthcheckInterval , "Healthcheck interval between each fetch." ))
143
+ flags .Bool ("healthcheck-startup" , false , flagUsageBool (false , "Healthcheck fetch on startup." ))
144
+
133
145
flags .Bool ("smtp-disable" , false , flagUsageBool (false , "Disable SMTP server." ))
134
146
flags .String ("smtp-host" , "" , flagUsageString ("" , "SMTP host address to listen on." ))
135
147
flags .Int ("smtp-port" , 0 , flagUsageInt (int (RawDefault .SMTPPort ), "SMTP port to listen on." ))
@@ -306,7 +318,15 @@ func (p Parser) Parse(raw Raw) (Config, error) {
306
318
307
319
// imapAddress := raw.IMAPHost + ":" + strconv.Itoa(int(raw.IMAPPort))
308
320
321
+ healthcheckInterval , err := time .ParseDuration (raw .HealthcheckInterval )
322
+ if err != nil {
323
+ return Config {}, err
324
+ }
325
+
309
326
return Config {
327
+ HealthcheckURL : raw .HealthcheckURL ,
328
+ HealthcheckInterval : healthcheckInterval ,
329
+ HealthcheckStartup : raw .HealthcheckStartup ,
310
330
Debug : raw .Debug ,
311
331
TimeHourFormat : timeHourFormat ,
312
332
DatabasePath : databasePath ,
0 commit comments