cdown / clipmenu

Clipboard management using dmenu
MIT License
1.11k stars 90 forks source link

clipmenud.service fails to start on boot up #147

Closed indradhanush closed 3 years ago

indradhanush commented 3 years ago

First of all I want to thank the maintainer and the contributors for this project which helps me a lot in my daily workflow. Now, on boot up, the clipmenud.service fails to start and here's the following log:

 $ systemctl status --user clipmenud.service
● clipmenud.service - Clipmenu daemon
     Loaded: loaded (/usr/lib/systemd/user/clipmenud.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2020-11-23 15:46:10 IST; 4min 9s ago
    Process: 1367 ExecStart=/usr/bin/clipmenud (code=exited, status=2)
   Main PID: 1367 (code=exited, status=2)

Nov 23 15:46:10 tpd systemd[1243]: clipmenud.service: Scheduled restart job, restart counter is at 5.
Nov 23 15:46:10 tpd systemd[1243]: Stopped Clipmenu daemon.
Nov 23 15:46:10 tpd systemd[1243]: clipmenud.service: Start request repeated too quickly.
Nov 23 15:46:10 tpd systemd[1243]: clipmenud.service: Failed with result 'exit-code'.
Nov 23 15:46:10 tpd systemd[1243]: Failed to start Clipmenu daemon.

Here's my clipmenud.service file:

[Unit]
Description=Clipmenu daemon

[Service]
ExecStart=/usr/bin/clipmenud
Restart=always
RestartSec=500ms

MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
ProtectControlGroups=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=
RestrictRealtime=yes

# We don't need to do any clean up, so if something hangs (borked xclip, etc),
# it's going to stay that way. Just forcefully kill and get it over with.
TimeoutStopSec=2

[Install]
WantedBy=default.target

I believe the issue stems from the RestartSec being set to 500ms. And maybe setting it to 2500ms could fix the issue. Do we want to fix this in the repo? For now I have made the change to my copy of the sytsemd unit file and would be happy to send in a PR for this if there was approval to do it. I should mention that I haven't yet tested this fix as the issue only props up when I boot up and a normal systemd restart or a systemd start works once I've already booted up and logged into my desktop.

I am on Arch Linux + i3wm.

$ uname -a
Linux tpd 5.9.9-arch1-1 #1 SMP PREEMPT Wed, 18 Nov 2020 19:52:04 +0000 x86_64 GNU/Linux
cdown commented 3 years ago

Hey! This just looks like your X server isn't started yet. You shouldn't start clipmenu until your X server is launched -- you need to either not launch the unit until you're sure that's complete, or use systemd's unit ordering to order it after X11. However, there is no standard X11 unit/target, so we can't package that.

RestartSec tweaking isn't an acceptable fix -- this is a legitimate failure.

indradhanush commented 3 years ago

Thank you @cdown. This makes sense. I will try to tweak my service definition to start after X11.

BachoSeven commented 3 years ago

@indradhanush This comment on a similar issue suggests just starting the user service from your .xinitrc instead of having to tweak it in order to enable it, this way you can be sure X11 has started.