You are not logged in.

#1 2012-12-07 16:50:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

[SOLVED] offlineimap started from service file - not syncing

I have recently started using offlineimap to sync my imap emails to a maildir folder.

Offlineimap syncs as expected when run from the command line.  I can also launch and background it from my xinitrc and it works as expected.  But when I use the .service file in the wiki here offlineimap will not sync.

I have created "offlineimap-user.service" file with that content, correctly changing the username to my user.  I have placed that file in /etc/systemd/system/multi-user.target.wants/ and it does start as confirmed by the following:

$ systemctl | grep offline
offlineimap-user.service    loaded active running   Start offlineimap as a daemon

Offlineimap also shows up in pstree/htop as running when started from the service file.  However, when started this way it never actually syncs.  When I kill the backgrounded process and restart it with `nohup offlineimap &` it then immediately syncs.

I have noticed that when started manually (or from xinitrc) offlineimap starts 7-8 processes or threads.  When started from the service file there are only 3 threads for it.

Does anyone have this service file working or know what I may be missing?

EDIT: I have found that restarting the service file once the system is up and running leads to successful syncing.  This leads me to suspect it may be being launched to early.  Is there an "after" clause that should be added to the service file?

Last edited by Trilby (2012-12-08 04:37:08)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#2 2012-12-07 23:50:51

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] offlineimap started from service file - not syncing

I am not sure about this, but I would have to imagine that you should at least have After=network.target.  Maybe it is just trying to start it way early, it is failing without network access and returning a non-zero? 

I have been running offlineimap as a cronjob for quite some time without issue.  I noticed the unit example you linked to is not a timer unit (or doesn't appear to have one), does this still continually update?  When my cronjob runs, it makes my cpu jump a tad for just a couple seconds, but I imagine that it must be better to not run this continually.

Offline

#3 2012-12-08 00:01:44

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] offlineimap started from service file - not syncing

From an old post of brisbin's that a lot of us use to setup offlineimap:

Offlineimap is kind of buggy for me; if I use its built-in refresh mechanism, I find it’ll often hang or quit and I’ll be left with an unsynced mailbox. Therefore, I choose to set offlineimap to never refresh and put a [re]start script in a cronjob to take care of it.

I dunno if that's a related or even still an issue now...are you using 'autorefresh' in offlineimaprc?

Scott

Offline

#4 2012-12-08 00:17:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] offlineimap started from service file - not syncing

I am using autorefresh in offlineimaprc, and it has worked well for me.  Once I do a `systemctl restart offlineimap-user` it syncs and continues to refresh indefinitely.

I also can't use a after=network.service as I have no network service.  I connect manually after starting up.

I have tested starting the offlineimap-user service manually after boot but prior to connecting to a network, it starts fine but of course does nothing useful until I connect to a network.  In those cases, after I connect to a network it proceeds to sync as expected.  This would seem to indicate it is not a reliance on a network connection to start properly.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2012-12-08 03:16:47

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] offlineimap started from service file - not syncing

Okay, I have set up my offlineimap to use a service, following the advice of the wiki and setting the suggested values in my offlineimaprc.  I am going to enable it and reboot... we'll see what happens...


Update: So I just rebooted, and all is working I think.  It certainly doesn't indicate that it has failed.  I sent mysefl and email before rebooting, so let me check...it's there.  I did in fact add the After=network.target and I do use net-auto-wireless, so maybe that has something to do with it.  Can you possibly test to see if it works when you have an actual network service of some kind?

Update2: Okay, so I realized that it had synced because I forgot to stop my cron job.  But after a couple more reboot tests, I have noticed that if I use net-auto-wireless, the service fails because it cannot connect to imap.gmail.com and then just doesn't try to reestablish (not sure if it will eventually).  But if I use netcfg@ or netcfg, the network.target is not actually reached until the connection is established.  Net-auto-wireless, because it is for roaming support, "finishes" well before it even starts to connect to a network it seems.

Last edited by WonderWoofy (2012-12-08 03:44:23)

Offline

#6 2012-12-08 03:44:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] offlineimap started from service file - not syncing

Eh ... I wouldn't even know where to start with that.  I don't have any sort of network management that could be put into a service file.

But even without any network connection at any point, when the service file is started while booting only 3 processes are launched, when it is started after booting (still without network) 7 processes are launched.

How many processes/threads does offlineimap create for you?

EDIT: I suppose on this (home) computer I can set up a dhcpcd service ... I'll try that.  That does indeed work on my home computer, but there would be no way to implement that on my laptop which is the only computer on which I really need offlineimap.  A service file that only works with an "always on" internet connection for a service who's sole purpose is to help with intermittent internet connectivity doesn't make much sense.

On my laptop, though, I can start the service after fully starting up even without a network connection and it works properly and syncs at any time there is a connection available.  It will not however do this when the service is started while booting - so there is yet another difference between the boot time starting and the post-boot time starting of the service.  I'm hoping I can find what that is.

Last edited by Trilby (2012-12-08 04:13:45)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2012-12-08 04:23:48

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] offlineimap started from service file - not syncing

There are a lot.  I count at lease thirty, but I also am connecting to three accounts with maxsyncaccouns = 3 in my offlineimaprc.

Offline

#8 2012-12-08 04:36:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: [SOLVED] offlineimap started from service file - not syncing

I'll double check on my laptop tomorrow ... I could swear I started the service before connecting to the network, and it still worked.  But if I'm wrong on that it seems the service file would not be a useful way to start this on my laptop.

Thanks for the help - I'll mark this as solved at this point and assume I must be mistaken about what I thought happened on my laptop until I can check/verify it tomorrow.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB