any1 / wayvnc

A VNC server for wlroots based Wayland compositors
ISC License
1.15k stars 69 forks source link

Support for systemd sockets? #357

Open Ra2-IFV opened 5 hours ago

Ra2-IFV commented 5 hours ago

Useful information:

Please, try to gather as much of useful information as possible and follow these instructions:

0.8.0-2

Info: Capturing output OUTPUT
Info: >> Headless output 11 1920x1080+0x0 Power:ON
Info: -- MONITOR 0000000000000 (HDMI-1) 1920x1080+0x0 Power:ON
ERROR: ../wayvnc/src/main.c: 893: Failed to bind to address. Add -Ldebug to the argument list for more info.
Process 100000 (wayvnc) of user 10000 dumped core.

Stack trace of thread 626156:
#0  0x000073d0600d4984 aml_ref (libaml.so.0 + 0x2984)
#1  0x000073d0600d53c8 aml_stop (libaml.so.0 + 0x33c8)
#2  0x00005ada052260ba n/a (wayvnc + 0xb0ba)
#3  0x00005ada05227a9b n/a (wayvnc + 0xca9b)
#4  0x00005ada0522083e n/a (wayvnc + 0x583e)
#5  0x000073d05fe42e08 n/a (libc.so.6 + 0x25e08)
#6  0x000073d05fe42ecc __libc_start_main (libc.so.6 + 0x25ecc)
#7  0x00005ada05221395 n/a (wayvnc + 0x6395)
ELF object binary architecture: x86-64

wayvnc.socket

[Unit]
Description=WayVNC socket

[Socket]
ListenStream=0.0.0.0:5901

[Install]
WantedBy=sockets.target

wayvnc.service

[Unit]
After=network.target

[Service]
Type=simple
Environment='WAYLAND_DISPLAY=wayland-0'
ExecStart=wayvnc -Ltrace --unix-socket

config

# address=0.0.0.0
# port=5901

enable_auth=false

use_relative_paths=true
layercak3 commented 4 hours ago

There is support via the external listener fd feature introduced in 0.9.0 (but not the specific sd_listen_fds(3) protocol). With your set of units you would use ExecStart=wayvnc [...] -x 3 to treat the address argument (3) as an fd which is where systemd's socket would be accessible from. You should also have Requires=wayvnc.socket in the [Unit] section of wayvnc.service in case you ever start wayvnc.service manually without it being triggered by socket activation, otherwise wayvnc would start with fd 3 being unusable.

Ra2-IFV commented 2 hours ago

My distro is still on 0.8.0 I'll report once I got the update.