I'm trying to run a script that launches a vlc process from a systemd service. The script works fine if I launch it manually, but fails if I call it from systemd. The error I see in the logs is:
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [000055f6edc51430] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [000055f6edc628e0] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [000055f6edc628e0] main interface error: no suitable interface module
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [000055f6edb822a0] main libvlc error: interface "dbus,none" initialization failed
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [000055f6edc728f0] main interface error: no suitable interface module
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [000055f6edb822a0] main libvlc error: interface "globalhotkeys,none" initialization failed
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [000055f6edc728f0] dummy interface: using the dummy interface module...
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [00007ff32c9933a0] mux_ogg mux: Open
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [00007ff32c9973d0] main tls client error: cannot resolve www.example.com port 443: System error
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [00007ff32c9964d0] access stream error: HTTP connection failure
Oct 18 15:24:40 ip-172-31-13-123 python3[23937]: [00007ff32c9933a0] mux_ogg mux: Close
This is the systemd service:
[Unit]
Description=vlc service
After=kurento-media-server.service
StartLimitIntervalSec=0
[Service]
Type=simple
User=ubuntu
ExecStart=/usr/bin/python3 /usr/local/bin/start-vlc.py
[Install]
WantedBy=multi-user.target
This is my script:
#!/usr/bin/python3
import subprocess
subprocess.run("vlc -I rc -I dummy 'https://www.example.com/stream/5f7c91b21584ad57e798678c/interpreter0.sdp' ':sout=#transcode{vcodec=none,acodec=mp3,channels=1}:duplicate{dst=http{mux=ts,mime=,dst=:50001},dst=http{mux=ogg,mime=audio/ogg,dst=:50051/live.ogg}}' ':sout-keep' &", shell=True)
I'm running VLC version 3.0.8, systemd 237, Ubuntu 18.04.5
Anyone have a clue of what could be wrong?
Thanks