Skip to content

feat: Configurable poll rate for check-for-changes.sh#4450

Merged
casperklein merged 8 commits intodocker-mailserver:masterfrom
litetex:check-for-changes-configurable-sleep
Apr 23, 2025
Merged

feat: Configurable poll rate for check-for-changes.sh#4450
casperklein merged 8 commits intodocker-mailserver:masterfrom
litetex:check-for-changes-configurable-sleep

Conversation

@litetex
Copy link
Copy Markdown
Contributor

@litetex litetex commented Apr 20, 2025

Description

Makes the check-for-changes.sh execution interval configurable (see issue for details).

Picked a default value of 20 because

  • it roughly halfs the idle load
  • it's still reactive enough when changes occur

Fixes #4414

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change that does improve existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary, I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added information about changes made in this PR to CHANGELOG.md

@litetex litetex marked this pull request as ready for review April 20, 2025 21:51
Copy link
Copy Markdown
Member

@polarathene polarathene left a comment

Choose a reason for hiding this comment

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

Thanks for the PR :)

We have _POLL for Getmail and Fetchmail services, I think we can be consistent with that suffix.

Likewise DMS_ as a prefix to remove ambiguity. "Check for changes" is a legacy name, as the feature hasn't been officially documented yet we can just refer to it as "change detection". Retaining the script name reference in the changelog is fine though, added a link to the relevant docs page for more context (such as the default).

Comment thread CHANGELOG.md Outdated
Comment thread docs/content/config/environment.md Outdated
Comment thread target/scripts/check-for-changes.sh Outdated
while true; do
_check_for_changes
sleep 2
sleep ${CHECK_FOR_CHANGES_INTERVAL_SEC:-20}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
sleep ${CHECK_FOR_CHANGES_INTERVAL_SEC:-20}
sleep ${DMS_CONFIG_POLL:-2}

Pretty sure if the default is left at 20 it'll affect our CI tests without having the ENV updated there to reduce it.

While I understand wanting to have a more sane default than 2, this would negatively impact new users trying to setup their DMS instance based on our docs with the setup CLI, having to wait up to 20 seconds until the update is actually applied (the CLI will not wait, it updates the monitored config, then defers to check-for-changes.sh). As such it'd also be breaking for any automation reliant upon that existing default (like our CI).

Your main concern would be completely avoided should someone contribute watchexec, which for the majority of users would remove any polling entirely.


The other maintainers may request that this ENV is also handled here:

# This function sets almost all environment variables. This involves setting
# a default if no value was provided and writing the variable and its value
# to the VARS map.
function __environment_variables_general_setup() {

That's where defaults are usually set (and written to /etc/dms-settings), but since this is specifically for check-for-changes.sh and not likely to be prone to breakage/conflict, I'm not going to require it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The other maintainers may request that this ENV is also handled here:

# This function sets almost all environment variables. This involves setting
# a default if no value was provided and writing the variable and its value
# to the VARS map.
function __environment_variables_general_setup() {

That's where defaults are usually set (and written to /etc/dms-settings), but since this is specifically for check-for-changes.sh and not likely to be prone to breakage/conflict, I'm not going to require it.

For completeness, please add the new ENV to the list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@polarathene polarathene added area/scripts kind/improvement Improve an existing feature, configuration file or the documentation area/documentation labels Apr 21, 2025
@polarathene polarathene added this to the v15.1.0 milestone Apr 21, 2025
litetex and others added 3 commits April 21, 2025 12:06
Co-authored-by: Brennan Kinney <[email protected]>
* ENV var renamed
* Default line changed to match the format used with other poll ENV.
* Rewrote the description with reference links so users have better insight.

Co-authored-by: Brennan Kinney <[email protected]>
Pretty sure if the default is left at 20 it'll affect our CI tests without having the ENV updated there to reduce it.

While I understand wanting to have a more sane default than `2`, this would negatively impact new users trying to setup their DMS instance based on our docs with the `setup` CLI, having to wait up to 20 seconds until the update is actually applied (_the CLI will not wait, it updates the monitored config, then defers to `check-for-changes.sh`_). As such it'd also be breaking for any automation reliant upon that existing default (like our CI).

Co-authored-by: Brennan Kinney <[email protected]>
@litetex
Copy link
Copy Markdown
Contributor Author

litetex commented Apr 21, 2025

@polarathene

Thank you for the feedback.

I applied you changes accordingly :)

Comment thread target/scripts/check-for-changes.sh Outdated
@polarathene
Copy link
Copy Markdown
Member

Oh whoops, I applied the change suggestion from @casperklein before noticing his other feedback 😓

@litetex feel free to force push your own branch or pull that change and then commit the other change request.

LGTM thus far though 👍

@polarathene polarathene changed the title feat: Configurable check-for-changes.sh execution interval feat: Configurable poll rate for check-for-changes.sh Apr 21, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Documentation preview for this PR is ready! 🎉

Built with commit: bd76310

@casperklein casperklein merged commit f2e5891 into docker-mailserver:master Apr 23, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation area/scripts kind/improvement Improve an existing feature, configuration file or the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: Idle load - check-for-changes.sh improve execution interval

3 participants