-
Notifications
You must be signed in to change notification settings - Fork 89
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
Option for DavMail to abort on failure #360
Comments
The systemd file provided with DavMail is designed for headless mode so incompatible with O365Interactive. In your case you want to start the application on session start, correct? There is an open pull request related to systemd that may or may not help: Alternative is to use autostart to have DavMail started by the desktop environment. |
Thanks @mguessan
Yes, that's correct.
It actually works fine for me! Once I
Thanks. I'm not entirely sure if it's the Presumably this is by design. As above, the application is trying (but failing) to reconnect. I just think that it's being too clever, and for "proper" systemd integration it should just abort on failure instead.
Yes, that's possible. However, assuming the systemd job fails on ... uh... failure, the advantage is that systemd can auto-restart it. Presumably starting it once by the DE wouldn't allow for that. |
I've been bitten by this a lot recently, so I've designed a workaround. This script will monitor journalctl for four consecutive errors, then restart the systemd job. It works well for me, and davmail now correctly launches on boot. Create the script somewhere logical, e.g. #!/usr/bin/bash
# This script will monitor journalctl --user $service for $regex, then restart the service after $limit matches
# Related https://github.com/mguessan/davmail/issues/360
# Davmail tries to reconnect 4 times every 5 minutes, so unfortunately we are constrained to monitor the log for failure every 5 minutes.
# Alternatively we could compare the timestamps from journalctl
regex='davmail.exception.DavMailException: DavMail configuration exception'
service='davmail@<YOUR_INSTANCE>.service'
limit=4
# output singular or plural
function num_match_or_matches () {
printf '%s %s' ${1} match
if [ $1 -ne 1 ]; then
printf '%s' es
fi
}
while true; do
printf '%s\n' "Monitoring $service"
count=0
journalctl --user -u "$service" -f -n 0 |
while IFS= read -r line; do
if [[ "$line" =~ $regex ]]; then
((count++)) # increment count
printf '%s %s\n' "$(num_match_or_matches $count)" 'for expression' # log the current count
if [ $count -ge $limit ]; then
printf '%s\n' "Attempting to restart $service"
systemctl --user restart "$service"
break
fi
fi
done
printf '%s\n' 'Pausing for 30 seconds'
sleep 30 # give davmail a bit of time before trying again
done Create the systemd service, e.g. at [Unit]
Description=Restart davmail if it fails
[Service]
Type=simple
ExecStart=/<PATH_ABOVE>/check_davmail_failing
[Install]
WantedBy=default.target Then start and enable the service with |
I'm using the Arch Linux systemd service to launch DavMail. This generally works fine. However, DavMail often fails, usually when booting the computer. When it is failing, there is no tray icon (I have
davmail.server=false
). Presumably DavMail fails because the panel/tray/bus isn't available yet.While it's failing, I get the following loop in
journalctl
, repeated 4 times every 5 minutes.DavMail does try and reconnect, but none of these attempt work. From the message, presumably this is because it can't connect to the GUI session. The only way to get it working again is by manually restarting the systemd service.
Presumably in order to attempt reconnections, the DavMail process does not abort, and thus the systemd service itself reports as active.
There seem to be two issues here. Firstly, DavMail seems to be retrying the wrong thing. Instead of retrying to connect, it should (also) try and connect to the GUI session again.
However, given that DavMail cannot reconnect by itself, is there a way to get it abort on failure immediately instead? Then systemd can restart the service. Either way, does it seem "neater" for systemd to take care of reattempts anyway?
The text was updated successfully, but these errors were encountered: