On Wed, 24 Jan 2018, Yubin Ruan wrote:
On Mon, Jan 22, 2018 at 01:54:36PM +0100, Lennart Poettering wrote:
On So, 21.01.18 19:12, Yubin Ruan (ablacktsh...@gmail.com) wrote:

Hi,

I use offlineimap to synchronize my emails. I want it to do a synchronization
at system startup so recently I add a systemd service for it. However I always
get error like this:

   EOF occurred in violation of protocol (_ssl.c:590)

This suggests your network doesn't work when you invoke this.

    1. usually (after system startup) the same service is invoked by a timer
    and it works well so there is no problem with the script.

    2. I believe the network is reachable, because the system will
    auto-connect WIFI after system startup. Maybe the initialization order is
    not configured properly? If so please see my mail service file
    below.

Well, this is necessarily racy: your network setup races agains your
offlineimap invocation...

I got in the configuration file

 [Unit]
 After=network.target

Isn't this enough to get the initialization order right?

No, network.target is mostly about ordering things correctly during shutdown.

You need to do two things:

* Use After=network-online.target in your unit.
* Enable some _other_ service that detects when the network is "online" (whatever that means), and that is ordered Before=network-online.target.

If you are using systemd-networkd, for instance, this service is systemd-networkd-wait-online.service. If you are using NetworkManager, you want NetworkManager-wait-online.service.

See https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ for further details.
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to