Systemd file to restart Insync automatically [workaround]

Insync sometimes crashes and does not autostart again.

This systemd service file should take care of it.

[Unit]
Description=Insync Google Drive and Dropbox synchronizer
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
RemainAfterExit=yes
ExecStart=/usr/bin/insync start
ExecStop=/usr/bin/insync quit
Restart=on-failure
RestartSec=10

[Install]
WantedBy=plasma-workspace.target

Put it into ~/.config/systemd/user/insync.service

and run

systemctl --user daemon-reload
systemctl --user enable insync.service
systemctl --user start insync.service

And it will autostart on startup. You might want to remove what insync puts in /etc/xdg/autostart or whatever it uses to autostart. I wish Insync adapted it itself, systemd is meant for this.

1 Like

Thank you for sharing this in great detail, @drew. I will send this to our engineers and see if they have any input/feedback/further questions.

I had to do something similar as insync crashes every time I use the media keys.

My .service looks like this though:

[Unit]
Description=Insync Keep Alive
After=network-online.target graphical-session.target
Wants=network-online.target graphical-session.target

[Service]
Type=forking
ExecStart=/usr/bin/insync start
ExecStop=/usr/bin/insync quit
Restart=on-failure
RestartSec=30

[Install]
WantedBy=graphical-session.target

The two main differences are:

  • WantedBy=graphical-session.target will work for the main DEs rather than just KDE.
  • I would have thought RemainAfterExit=yes would have caused problems so this is missing from mine.

Yes, that is indeed better. I previously had oneshot where RemainAfterExit might have made sense, but I changed it to forking because it would not restart on failure, I just forgot to remove that line. I am changing it in the original post for people who do not read the comments, thanks for the suggestion!

Actually, now that I tried it, systemctl restart and systemctl start does not work without RemainAfterExit=yes. From what I can find, Insync is not forking itself properly, so systemd files to track it well. Systemd would like a PID file, but that is also not provided, as far as I can tell. But it seemed to me the restarting after a crash worked, I will keep an eye on it.