Skip to content

Commit

Permalink
Add letsencrypt.issue event
Browse files Browse the repository at this point in the history
  • Loading branch information
elct9620 committed Nov 7, 2023
1 parent fa8f55c commit 8070a7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ If you are using Sidekiq or others, you can enqueue renew task daily.
LetsEncrypt::RenewCertificatesJob.perform_later
```

### Subscribe

When the certificate is trying to issue a new one, you can subscribe it for logging or error handling.

```ruby
ActiveSupport::Notifications.subscribe('letsencrypt.issue') do |name, start, finish, id, payload|
Rails.logger.info("Certificate for #{payload[:domain]} is issued")
end
```

### ngx_mruby

The setup is following this [Article](http://hb.matsumoto-r.jp/entry/2017/03/23/173236)
Expand Down
4 changes: 3 additions & 1 deletion app/models/lets_encrypt/certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def expired?

# Returns true if success get a new certificate
def get
verify && issue
ActiveSupport::Notifications.instrument('letsencrypt.issue', domain: domain) do
verify && issue
end
end

alias renew get
Expand Down

0 comments on commit 8070a7e

Please sign in to comment.