Add option to disable watchdog and set default timeout to DB healthcheck
This commit is contained in:
parent
36d3b1e9fb
commit
e0557d8961
4 changed files with 18 additions and 2 deletions
|
@ -52,7 +52,7 @@ func startDaemon(store *storage.Storage) {
|
||||||
logger.Error("Unable to send readiness notification to systemd: %v", err)
|
logger.Error("Unable to send readiness notification to systemd: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if systemd.HasSystemdWatchdog() {
|
if config.Opts.HasWatchdog() && systemd.HasSystemdWatchdog() {
|
||||||
logger.Info("Activating Systemd watchdog")
|
logger.Info("Activating Systemd watchdog")
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -64,6 +64,7 @@ const (
|
||||||
defaultMetricsCollector = false
|
defaultMetricsCollector = false
|
||||||
defaultMetricsRefreshInterval = 60
|
defaultMetricsRefreshInterval = 60
|
||||||
defaultMetricsAllowedNetworks = "127.0.0.1/8"
|
defaultMetricsAllowedNetworks = "127.0.0.1/8"
|
||||||
|
defaultWatchdog = true
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultHTTPClientUserAgent = "Mozilla/5.0 (compatible; Miniflux/" + version.Version + "; +https://miniflux.app)"
|
var defaultHTTPClientUserAgent = "Mozilla/5.0 (compatible; Miniflux/" + version.Version + "; +https://miniflux.app)"
|
||||||
|
@ -128,6 +129,7 @@ type Options struct {
|
||||||
metricsCollector bool
|
metricsCollector bool
|
||||||
metricsRefreshInterval int
|
metricsRefreshInterval int
|
||||||
metricsAllowedNetworks []string
|
metricsAllowedNetworks []string
|
||||||
|
watchdog bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOptions returns Options with default values.
|
// NewOptions returns Options with default values.
|
||||||
|
@ -183,6 +185,7 @@ func NewOptions() *Options {
|
||||||
metricsCollector: defaultMetricsCollector,
|
metricsCollector: defaultMetricsCollector,
|
||||||
metricsRefreshInterval: defaultMetricsRefreshInterval,
|
metricsRefreshInterval: defaultMetricsRefreshInterval,
|
||||||
metricsAllowedNetworks: []string{defaultMetricsAllowedNetworks},
|
metricsAllowedNetworks: []string{defaultMetricsAllowedNetworks},
|
||||||
|
watchdog: defaultWatchdog,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,6 +460,11 @@ func (o *Options) HTTPClientUserAgent() string {
|
||||||
return o.httpClientUserAgent
|
return o.httpClientUserAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasWatchdog returns true if the systemd watchdog is enabled.
|
||||||
|
func (o *Options) HasWatchdog() bool {
|
||||||
|
return o.watchdog
|
||||||
|
}
|
||||||
|
|
||||||
// SortedOptions returns options as a list of key value pairs, sorted by keys.
|
// SortedOptions returns options as a list of key value pairs, sorted by keys.
|
||||||
func (o *Options) SortedOptions() []*Option {
|
func (o *Options) SortedOptions() []*Option {
|
||||||
var keyValues = map[string]interface{}{
|
var keyValues = map[string]interface{}{
|
||||||
|
@ -512,6 +520,7 @@ func (o *Options) SortedOptions() []*Option {
|
||||||
"SCHEDULER_SERVICE": o.schedulerService,
|
"SCHEDULER_SERVICE": o.schedulerService,
|
||||||
"SERVER_TIMING_HEADER": o.serverTimingHeader,
|
"SERVER_TIMING_HEADER": o.serverTimingHeader,
|
||||||
"WORKER_POOL_SIZE": o.workerPoolSize,
|
"WORKER_POOL_SIZE": o.workerPoolSize,
|
||||||
|
"WATCHDOG": o.watchdog,
|
||||||
}
|
}
|
||||||
|
|
||||||
keys := make([]string, 0, len(keyValues))
|
keys := make([]string, 0, len(keyValues))
|
||||||
|
|
|
@ -189,6 +189,8 @@ func (p *Parser) parseLines(lines []string) (err error) {
|
||||||
p.opts.metricsAllowedNetworks = parseStringList(value, []string{defaultMetricsAllowedNetworks})
|
p.opts.metricsAllowedNetworks = parseStringList(value, []string{defaultMetricsAllowedNetworks})
|
||||||
case "FETCH_YOUTUBE_WATCH_TIME":
|
case "FETCH_YOUTUBE_WATCH_TIME":
|
||||||
p.opts.fetchYouTubeWatchTime = parseBool(value, defaultFetchYouTubeWatchTime)
|
p.opts.fetchYouTubeWatchTime = parseBool(value, defaultFetchYouTubeWatchTime)
|
||||||
|
case "WATCHDOG":
|
||||||
|
p.opts.watchdog = parseBool(value, defaultWatchdog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
package storage // import "miniflux.app/storage"
|
package storage // import "miniflux.app/storage"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage handles all operations related to the database.
|
// Storage handles all operations related to the database.
|
||||||
|
@ -31,7 +33,10 @@ func (s *Storage) DatabaseVersion() string {
|
||||||
|
|
||||||
// Ping checks if the database connection works.
|
// Ping checks if the database connection works.
|
||||||
func (s *Storage) Ping() error {
|
func (s *Storage) Ping() error {
|
||||||
return s.db.Ping()
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
return s.db.PingContext(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DBStats returns database statistics.
|
// DBStats returns database statistics.
|
||||||
|
|
Loading…
Reference in a new issue