Skip to content

Conversation

niol
Copy link

@niol niol commented Dec 13, 2021

No description provided.

@peterhoeg
Copy link

The build fails on windows as com.sun.jna isn't available there. I am not at all familiar with the java build environment, but surely there is a way to gate it or gracefully handle the failing import

try {
Class.forName("davmail.util.SystemdNotify").getMethod("ready").invoke(null);
} catch (Exception e) {
LOGGER.warn("Running on a systemD host but could not notify reaydness.");
Copy link

@esabol esabol Jun 17, 2025

Choose a reason for hiding this comment

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

"Readiness" is misspelled here. Please fix.

Also, capitalizing the "d" in "systemd" is a bit unusual. Wikipedia refers to it as "systemd".

I suggest rephrasing the first part as "Running on a host with systemd" etc.

@peterhoeg
Copy link

I think we need to consider a few different cases here (for Linux only).

davmail runs as a:

  1. system service handled by systemd
  2. user service handled by systemd
  3. system service not handled by systemd
  4. user service not handled by systemd
  5. user service not handled by systemd but systemd is otherwise in use on the system

I would argue that instead of trying to handle all the various cases, simply try to notify systemd. If it works, great. If it doesn't, then simply continue without any systemd special cases.

The whole idea of checking for directories to see if systemd is used is bound to cause issues. If you really want to check, see if the environment variable $INVOCATION_ID is set before triggering the notify call.

The next step would then be to use the watchdog function to notify systemd that davmail is still alive and kicking if configured to do so:

https://www.freedesktop.org/software/systemd/man/latest/sd_watchdog_enabled.html#

@peterhoeg
Copy link

My apologies for my comments arriving in bits and pieces. I unfortunately haven't had the time to sit down and think this through properly.

If we are changing the .service file to Type = oneshot, the service will fail if we for whatever reason are not able to notify systemd so the warning should probably be an error in this case.

I don't know enough about the various failure modes or why we wouldn't be able to notify systemd when run under it, but just to be friendly to the end user, I suggest bailing out with an informative error message.

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.

4 participants