File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,7 +73,18 @@ func (a *CertWebhookApp) Provision(ctx caddy.Context) error {
7373 zap .Bool ("gateway_secret_set" , a .GatewaySecret != "" ),
7474 zap .Duration ("throttle_interval" , a .throttleInterval ))
7575
76- return a .Config .Validate ()
76+ if err := a .Config .Validate (); err != nil {
77+ return err
78+ }
79+
80+ // Subscribe to events during provisioning, before the events app starts.
81+ // Caddy's event bus rejects new subscriptions after Start() is called.
82+ if err := a .subscribeToEvents (ctx ); err != nil {
83+ a .logger .Error (LogMsgFailedToSubscribeToEvents , zap .Error (err ))
84+ return err
85+ }
86+
87+ return nil
7788}
7889
7990func (a * CertWebhookApp ) Start () error {
@@ -88,11 +99,6 @@ func (a *CertWebhookApp) Start() error {
8899
89100 a .delivery = NewWebhookDelivery (a .portal .Websites (), a .logger )
90101
91- if err := a .subscribeToEvents (a .ctx ); err != nil {
92- a .logger .Error (LogMsgFailedToSubscribeToEvents , zap .Error (err ))
93- return err
94- }
95-
96102 a .logger .Info (LogMsgStarted ,
97103 zap .String ("portal_url" , a .PortalURL ))
98104
You can’t perform that action at this time.
0 commit comments