Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "goalert", Short: "Alerting platform.", RunE: func(cmd *cobra.Command, args []string) error { if viper.GetBool("json") { log.EnableJSON() } if viper.GetBool("verbose") { log.EnableVerbose() } err := viper.ReadInConfig() if _, ok := err.(viper.ConfigFileNotFoundError); err != nil && !ok { return errors.Wrap(err, "read config") } ctx := context.Background() cfg, err := getConfig() if err != nil { return err } exporters, err := configTracing(ctx, cfg) if err != nil { return errors.Wrap(err, "config tracing") } defer func() { // flush exporters type flusher interface { Flush() } for _, e := range exporters { if f, ok := e.(flusher); ok { f.Flush() } } }() wrappedDriver := sqltrace.WrapDriver(&pq.Driver{}, &sqltrace.WrapOptions{Query: true, Args: true}) u, err := url.Parse(cfg.DBURL) if err != nil { return errors.Wrap(err, "parse old URL") } q := u.Query() if cfg.DBURLNext != "" { q.Set("application_name", "GoAlert (Switch-Over Mode)") } else { q.Set("application_name", "GoAlert") } u.RawQuery = q.Encode() cfg.DBURL = u.String() dbc, err := wrappedDriver.OpenConnector(cfg.DBURL) if err != nil { return errors.Wrap(err, "connect to postgres") } var db *sql.DB var h *switchover.Handler if cfg.DBURLNext != "" { u, err := url.Parse(cfg.DBURLNext) if err != nil { return errors.Wrap(err, "parse next URL") } q := u.Query() q.Set("application_name", "GoAlert (Switch-Over Mode)") u.RawQuery = q.Encode() cfg.DBURLNext = u.String() dbcNext, err := wrappedDriver.OpenConnector(cfg.DBURLNext) if err != nil { return errors.Wrap(err, "connect to postres (next)") } h, err = switchover.NewHandler(ctx, dbc, dbcNext, cfg.DBURL, cfg.DBURLNext) if err != nil { return errors.Wrap(err, "init changeover handler") } db = h.DB() } else { db = sql.OpenDB(dbc) } app, err := NewApp(cfg, db) if err != nil { return errors.Wrap(err, "init app") } if h != nil { h.SetApp(app) } go handleShutdown(ctx, func(ctx context.Context) error { if h != nil { h.Abort() } return app.Shutdown(ctx) }) trigCh := make(chan os.Signal, 1) signal.Notify(trigCh, triggerSignals...) go func() { for range trigCh { app.Trigger() } }() return errors.Wrap(app.Run(ctx), "run app") }, }
RootCmd is the configuration for running the app binary.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
ConfigStore *config.Store
AlertStore alert.Store
AlertlogStore alertlog.Store
UserStore user.Store
ContactMethodStore contactmethod.Store
NotificationRuleStore notificationrule.Store
FavoriteStore favorite.Store
ServiceStore service.Store
EscalationStore escalation.Store
IntegrationKeyStore integrationkey.Store
ScheduleRuleStore rule.Store
NotificationStore notification.Store
ScheduleStore schedule.Store
RotationStore rotation.Store
OverrideStore override.Store
Resolver resolver.Resolver
LimitStore limit.Store
HeartbeatStore heartbeat.Store
OAuthKeyring keyring.Keyring
SessionKeyring keyring.Keyring
NonceStore nonce.Store
LabelStore label.Store
OnCallStore oncall.Store
NCStore notificationchannel.Store
TimeZoneStore *timezone.Store
// contains filtered or unexported fields
}
App represents an instance of the GoAlert application.
func (*App) ActiveRequests ¶
ActiveRequests returns the current number of active requests, not including pending ones during pause.
func (*App) Shutdown ¶
Shutdown will cause the App to begin a graceful shutdown, using the provided context for any cleanup operations.
Source Files
¶
- app.go
- appconfig.go
- clusterexporter.go
- cmd.go
- concurrencylimiter.go
- contextlocker.go
- cooldown.go
- getsetconfig.go
- healthcheck.go
- initauth.go
- initengine.go
- initgraphql.go
- inithttp.go
- inithttputil.go
- initslack.go
- initstores.go
- inittwilio.go
- listenevents.go
- listenstatus.go
- logexporter.go
- middleware.go
- middlewaregzip.go
- middlewarereqlimit.go
- pause.go
- recoverexporter.go
- runapp.go
- shutdown.go
- shutdownsignals_unix.go
- startup.go
- tracing.go
- trigger.go
- version.go
Click to show internal directories.
Click to hide internal directories.