Skip to content

scripts: refactored daemon-stack.sh#2496

Merged
georglauterbach merged 12 commits intomasterfrom
scripts/update/daemon-stack
Mar 27, 2022
Merged

scripts: refactored daemon-stack.sh#2496
georglauterbach merged 12 commits intomasterfrom
scripts/update/daemon-stack

Conversation

@georglauterbach
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach commented Mar 21, 2022

Description

The file target/scripts/startup/daemons-stack.sh is refactored with this PR. It was cluttered with Fetchmail setup, which was relocated. A common daemon startup routine was introduced with proper logging. The log will now show startup information on log level debug or trace, and output from Supervisor is only shown on error. The currently present

<DAEMON>: started

is therefore not shown anymore during startup. On the right log level, the information can be obtained:

[  DEBUG  ]  Starting <DAEMON>

Functionality-wise, this PR changes nothing. This is just a refactoring.

Type of change

  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own 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

A new method was introduced to uniformaly start daemons and log output
accordingly. The methods for daemon start were renamed (plural ->
singular), therefore the adjustments in `start-mailserver.sh`.
Not sure why, but the Fetchmail setup was somehow happening in
`daemon-stack.sh` - this is not supposed to be the case. I relocated the
setup into `setup-stack.sh`, where it belong.
These are unused leftovers from the last commit, that relocated the
setup of Fetchmail into `setup.stack.sh`.
@georglauterbach georglauterbach added area/scripts kind/improvement Improve an existing feature, configuration file or the documentation labels Mar 21, 2022
@georglauterbach georglauterbach added this to the v11.0.0 milestone Mar 21, 2022
@georglauterbach georglauterbach self-assigned this Mar 21, 2022
@georglauterbach georglauterbach marked this pull request as draft March 21, 2022 12:02
polarathene
polarathene previously approved these changes Mar 22, 2022
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.

These diffs were not pleasant to review (at least via the Github UI). I went through individual commits, but these were not tailored to improve the diff experience 😅

LGTM though, nice improvements 👍

Comment thread target/scripts/startup/daemons-stack.sh Outdated
Comment thread target/scripts/startup/daemons-stack.sh Outdated
@polarathene
Copy link
Copy Markdown
Member

Test failure:

not ok 300 checking setup.sh: setup.sh debug fetchmail in [315](https://github.com/docker-mailserver/docker-mailserver/runs/5625535875?check_suite_focus=true#step:8:315)ms
# (from function `assert_output' in file test/test_helper/bats-assert/src/assert.bash, line 231,
#  in test file test/tests.bats, line 1128)
#   `assert_output --partial "fetchmail: normal termination, status 11"' failed
# 
# -- output does not contain substring --
# substring (1 lines):
#   fetchmail: normal termination, status 11
# output (2 lines):
#   /usr/local/bin/debug-fetchmail: line 3: /usr/local/bin/setup-fetchmail: No such file or directory
#   fetchmail: no mailservers have been specified.
# --

Since you migrated the fetchmail scripts to setup-stack.sh, you now have this failure trying to run _setup_fetchmail() that you'll need to resolve:

/usr/local/bin/setup-fetchmail

@georglauterbach
Copy link
Copy Markdown
Member Author

These diffs were not pleasant to review (at least via the Github UI). I went through individual commits, but these were not tailored to improve the diff experience sweat_smile

Yes, the diff is very ugly...

LGTM though, nice improvements +1

Thanks!

It is absolutely fine to source `setup-stack.sh` because sourcing the
script does not execute a single function (by desing of the script).
This way, we retain functionality.
@georglauterbach
Copy link
Copy Markdown
Member Author

georglauterbach commented Mar 22, 2022

Test failure:

not ok 300 checking setup.sh: setup.sh debug fetchmail in [315](https://github.com/docker-mailserver/docker-mailserver/runs/5625535875?check_suite_focus=true#step:8:315)ms
# (from function `assert_output' in file test/test_helper/bats-assert/src/assert.bash, line 231,
#  in test file test/tests.bats, line 1128)
#   `assert_output --partial "fetchmail: normal termination, status 11"' failed
# 
# -- output does not contain substring --
# substring (1 lines):
#   fetchmail: normal termination, status 11
# output (2 lines):
#   /usr/local/bin/debug-fetchmail: line 3: /usr/local/bin/setup-fetchmail: No such file or directory
#   fetchmail: no mailservers have been specified.
# --

Since you migrated the fetchmail scripts to setup-stack.sh, you now have this failure trying to run _setup_fetchmail() that you'll need to resolve:

/usr/local/bin/setup-fetchmail

I fixed it by just sourcing setup-stack.sh. The commit message again explains why this is fine (sourcing the stack does not execute code until one calls the functions themselves). Tests pass locally, should now pass in GitHub's CI.

@georglauterbach georglauterbach marked this pull request as ready for review March 22, 2022 10:03
polarathene
polarathene previously approved these changes Mar 22, 2022
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.

I just sourced setup-stack.sh.

Still feels icky 😅 but I'm fine with it.

@georglauterbach
Copy link
Copy Markdown
Member Author

I just sourced setup-stack.sh.

Still feels icky sweat_smile but I'm fine with it.

Yes, my first thought as well, but then, when you think about it, it's just fine. It's not even hacky, because there are zero side effects - it just takes half a second longer :D

@georglauterbach
Copy link
Copy Markdown
Member Author

@casperklein what do you think about this PR? :)

Comment thread target/bin/debug-fetchmail
@georglauterbach georglauterbach merged commit a54d774 into master Mar 27, 2022
@georglauterbach georglauterbach deleted the scripts/update/daemon-stack branch March 27, 2022 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants