Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watchdog_interval method #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Mr0grog
Copy link

@Mr0grog Mr0grog commented Jun 26, 2024

This adds a new watchdog_interval method that returns the current watchdog interval in seconds (or 0 if no interval is set). Fixes #6.

A few notes here:

  • I tried to keep this simple by just adding a watchdog_interval method and not changing any other code. That said, it might be convenient if watchdog? returned false if disabled and the interval (instead of true) if enabled. That would work fine for most people (since floats are truthy), but might be subtly breaking if someone is literally comparing the return value to true.

  • Revised the docs for watchdog? a bit to hopefully make them clearer for users who aren’t already deeply familiar with sd_notify, instead of focusing on under-the-hood bits like environment variables. Happy to change this back if you don’t like that.

  • Added tests for watchdog? since there weren’t any.

  • Added an example of using watchdog to the README. It’s a little complex! Let me know if you have ideas for making it simpler or clearer, or if I should remove it.

  • When I ran Rubocop, I got a huge number of errors, mostly from cops that are probably new since this gem last received a major update. I went ahead and turned most of them off in the config, although I did add required_ruby_version to the gemspec file since that seemed like a good idea. I set the value (>= 2.3.0 >= 2.2.0) based on the GitHub Actions CI job. Let me know if I should change or remove it.

Mr0grog added 3 commits June 26, 2024 15:34
This adds a `watchdog_interval` method as well as tests for it and for `watchdog?` (which previously had no tests). I also took the liberty of revising the docs for `watchdog?` to (I hope) be a little clearer.

Fixes agis#6.
Running Rubocop printed out a huge number of new warnings and errors. For the most part, I just silenced them since this gem has been pretty stable and I assume you don't want to modify things just to match newer recommendations. I did add `required_ruby_version` to the gemspec, though, since that just seems like a good idea. It's set to 2.3.0, based on the GitHub Actions CI job.
@Mr0grog Mr0grog mentioned this pull request Jun 26, 2024
Comment on lines +4 to +6
AllCops:
TargetRubyVersion: 2.2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how many cops I had to turn off in this PR, it might be better to disable them all here and explicitly turn on the ones you want. I’m not sure which you want, though, so I just turned off all the new and/or error-triggering ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get watchdog interval
1 participant