pulb / mailnag

An extensible mail notification daemon
GNU General Public License v2.0
250 stars 32 forks source link

possible workarounds for Mailnag issue? #226

Open LexClone opened 2 years ago

LexClone commented 2 years ago

Is there a way to restart the daemon, say every 30 minutes? I can set up a cronjob but I don't know how to make mailnag restart in such a job. I am looking for a workaround for an issue:

Mailnag mostly works great for me. I use it with Claws-Mail which only does polling at intervals. With Mailnag I get near instant notification for new msgs. The issue is that it stops working after a while, maybe a couple of hours, maybe as much as a day.

Any suggestions are appreciated. My set up is:

Mailnag 2.2.0

NordVPN Version 3.10.0

OS: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal Kernel 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Recent output from journalctl -b _COMM=mailnag Sep 25 14:46:36 troy mailnag[1929]: INFO (2021-09-25 14:46:36): Successfully enabled plugin 'userscriptplugin'. Sep 25 14:46:36 troy mailnag[1929]: ERROR (2021-09-25 14:46:36): Caught an exception. Traceback (most recent call last): File "/usr/lib/python3/dist-packages/Mailnag/daemon/mailnagdaemon.py", line 165, in _start if not self._wait_for_inet_connection(): File "/usr/lib/python3/dist-packages/Mailnag/daemon/mailnagdaemon.py", line 212, in _wait_for_inet_connection if self._conntest.is_offline(): File "/usr/lib/python3/dist-packages/Mailnag/daemon/conntest.py", line 47, in is_offline return (not self._monitor.can_reach(Gio.NetworkAddress.new(TEST_HOST, 8080))) gi.repository.GLib.GError: g-resolver-error-quark: Error resolving “www.google.com”: Temporary failure in name resolution (1) Sep 25 14:46:36 troy mailnag[1929]: INFO (2021-09-25 14:46:36): Shutting down... Sep 25 14:46:36 troy mailnag[1929]: INFO (2021-09-25 14:46:36): Plugins disabled successfully. Sep 27 14:02:13 troy mailnag[31031]: INFO (2021-09-27 14:02:13): Successfully enabled plugin 'userscriptplugin'. Sep 27 14:02:13 troy mailnag[31031]: INFO (2021-09-27 14:02:13): Checking 1 email account(s). ......

-- Logs begin at Mon 2021-08-16 19:15:28 CDT, end at Tue 2021-09-28 10:36:04 CDT. -- Sep 27 23:11:20 troy mailnag[3307]: INFO (2021-09-27 23:11:20): Successfully enabled plugin 'userscriptplugin'. Sep 27 23:11:20 troy mailnag[3307]: INFO (2021-09-27 23:11:20): Checking 1 email account(s). Sep 27 23:13:30 troy mailnag[3307]: ERROR (2021-09-27 23:13:30): Failed to open mailbox for account 'giPaxemail' ([Errno 110] Connection timed out). Sep 27 23:24:37 troy mailnag[3307]: INFO (2021-09-27 23:24:37): Checking 1 email account(s). Sep 27 23:34:37 troy mailnag[3307]: INFO (2021-09-27 23:34:37): Checking 1 email account(s). Sep 28 00:00:59 troy mailnag[3307]: ERROR (2021-09-28 00:00:59): Idle callback for account 'giPaxemail' returned an error (<class 'Mailnag.common.imaplib2.IMAP4.abort'> - socket error: <class 'OSError'> - [Errno 101] Network is unreachable). Sep 28 00:00:59 troy mailnag[3307]: INFO (2021-09-28 00:00:59): Resetting connection for account 'giPaxemail' Sep 28 00:00:59 troy mailnag[3307]: INFO (2021-09-28 00:00:59): Idler thread for account 'giPaxemail' has been disconnected Sep 28 00:00:59 troy mailnag[3307]: INFO (2021-09-28 00:00:59): Trying to reconnect Idler thread for account 'giPaxemail'. Sep 28 00:01:00 troy mailnag[3307]: INFO (2021-09-28 00:01:00): Successfully reconnected Idler thread for account 'giPaxemail'. Sep 28 00:01:00 troy mailnag[3307]: INFO (2021-09-28 00:01:00): Checking 1 email account(s). ... Sep 28 02:31:04 troy mailnag[3307]: INFO (2021-09-28 02:31:04): Checking 1 email account(s). Sep 28 02:37:55 troy mailnag[3307]: ERROR (2021-09-28 02:37:55): Idle callback for account 'giPaxemail' returned an error (<class 'Mailnag.common.imaplib2.IMAP4.abort'> - socket error: <class 'OSError'> - Too many read 0). Sep 28 02:37:55 troy mailnag[3307]: INFO (2021-09-28 02:37:55): Resetting connection for account 'giPaxemail' Sep 28 02:37:55 troy mailnag[3307]: INFO (2021-09-28 02:37:55): Idler thread for account 'giPaxemail' has been disconnected Sep 28 02:37:55 troy mailnag[3307]: INFO (2021-09-28 02:37:55): Trying to reconnect Idler thread for account 'giPaxemail'. Sep 28 02:37:55 troy mailnag[3307]: INFO (2021-09-28 02:37:55): Successfully reconnected Idler thread for account 'giPaxemail'. Sep 28 02:37:55 troy mailnag[3307]: INFO (2021-09-28 02:37:55): Checking 1 email account(s). ... Sep 28 06:01:02 troy mailnag[3307]: INFO (2021-09-28 06:01:02): Checking 1 email account(s). Sep 28 06:01:02 troy mailnag[3307]: DEBUG (2021-09-28 06:01:02): Couldn't get Message-ID from message. Sep 28 06:11:02 troy mailnag[3307]: INFO (2021-09-28 06:11:02): Checking 1 email account(s). Sep 28 06:11:02 troy mailnag[3307]: DEBUG (2021-09-28 06:11:02): Couldn't get Message-ID from message. Sep 28 06:11:40 troy mailnag[3307]: INFO (2021-09-28 06:11:40): Checking 1 email account(s). ...

Matthew-Wai commented 1 year ago

Is there a way to restart the daemon, say every 30 minutes? I can set up a cronjob but I don't know how to make mailnag restart in such a job.

Have you tried the following in cronjob?

*/30 * * * * killall mailnag && sleep 5s && sudo -u $(whoami) DISPLAY=:0 "XDG_RUNTIME_DIR=/run/user/$(id -u $(whoami))" mailnag

Note that the above is one single line rather than two lines.