Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No logging as system daemon on Raspberry #1245

Open
2 of 6 tasks
Drexel2k opened this issue Dec 8, 2023 · 4 comments
Open
2 of 6 tasks

No logging as system daemon on Raspberry #1245

Drexel2k opened this issue Dec 8, 2023 · 4 comments
Labels
bug A functionality or parts of a program that do not work as intended

Comments

@Drexel2k
Copy link

Drexel2k commented Dec 8, 2023

Description
Hello,

when I configure spotifyd as a system service on a Raspberry Pi as described here: https://docs.spotifyd.rs/config/services/Systemd.html with

sudo systemctl enable spotifyd.service --now

I can't get it to write any logs. Either I have --no-daemon argument for ExecStart, then it works fine with logging, or I leave the argument out, then the daemon starts and stops immediately without any error.

On Raspberry syslog ist not installed, instead journald and spotifyd needs a syslog for writing logs from my understanding, therefore I also installed syslog, but it did make no change. Sorry I am not so deep in Linux topics...

Some kind of Journal support would be nice for the future.

To Reproduce

  1. Create spotifyd.service: sudo nano /etc/systemd/system/spotifyd.service
[Unit]
Description=A spotify playing daemon
Documentation=https://github.com/Spotifyd/spotifyd
Wants=sound.target
After=sound.target
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/spotifyd

[Install]
WantedBy=default.target
  1. Enter
sudo systemctl enable spotifyd.service --now
  1. Reboot
  2. Enter
ps -aux | grep spot
systemctl status spotifyd.service
  1. You see the process is not running but it didn't even shows an error

Expected behavior
The process should be running

Logs

Click to show logs
 spotifyd.service - A spotify playing daemon
     Loaded: loaded (/etc/systemd/system/spotifyd.service; enabled; preset: enabled)
     Active: inactive (dead) since Fri 2023-12-08 14:28:37 CET; 47s ago
   Duration: 214ms
       Docs: https://github.com/Spotifyd/spotifyd
    Process: 891 ExecStart=/usr/bin/spotifyd (code=exited, status=0/SUCCESS)
   Main PID: 891 (code=exited, status=0/SUCCESS)
        CPU: 24ms

Dec 08 14:28:37 raspifm systemd[1]: Started spotifyd.service - A spotify playing daemon.
Dec 08 14:28:37 raspifm spotifyd[891]: Loading config from "/etc/spotifyd.conf"
Dec 08 14:28:37 raspifm spotifyd[891]: No username specified. Checking username_cmd
Dec 08 14:28:37 raspifm spotifyd[891]: No username_cmd specified
Dec 08 14:28:37 raspifm spotifyd[891]: No password specified. Checking password_cmd
Dec 08 14:28:37 raspifm spotifyd[891]: No password_cmd specified
Dec 08 14:28:37 raspifm spotifyd[891]: No proxy specified
Dec 08 14:28:37 raspifm spotifyd[891]: Daemonizing running instance
Dec 08 14:28:37 raspifm spotifyd[899]: Detached from shell, now running in background.
Dec 08 14:28:37 raspifm systemd[1]: spotifyd.service: Deactivated successfully.

Compilation flags

  • dbus_mpris
  • dbus_keyring
  • alsa_backend
  • portaudio_backend
  • pulseaudio_backend
  • rodio_backend

Versions (please complete the following information):

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
cat: command: No such file or directory

spotifyd:5565f24
cargo: 1.74.1 (ecb9851af 2023-10-18)

Thank you in advance for any help!

@Drexel2k Drexel2k added the bug A functionality or parts of a program that do not work as intended label Dec 8, 2023
@eladyn
Copy link
Member

eladyn commented Dec 14, 2023

I already commented on that topic in your PR, but what's happening, is the following.

When running without --no-daemon, spotifyd forks itself into the background, so the main process terminates. (That's why systemd displays the service as exited. So when using systemd, you should use --no-daemon, since systemd should take care of daemonizing and watching the application.

In either case, spotifyd will log to journald (the syslog) and its messages should appear in journalctl --follow or journalctl --user --follow in user sessions.

@Drexel2k
Copy link
Author

When running without --no-daemon, spotifyd forks itself into the background, so the main process terminates. (That's why systemd displays the service as exited. So when using systemd, you should use --no-daemon, since systemd should take care of daemonizing and watching the application.

Ah ok, I wasn't fully aware what the --no-daemon flag does, I read somewhere that it is just about logging output redirection. Maybe this is also an info, which could be in the docs. ;)

I thought when running as a daemon, it would make sense to leave out the --no-daemon flag... But I think I remember when you leave the flag out as daemon, there is no spotifyd process at all running at startup, maybe the fork doesn't work then. But I am not sure, I will check this out in the next days.

In either case, spotifyd will log to journald (the syslog) and its messages should appear in journalctl --follow or journalctl --user --follow in user sessions.

I will also check this out. As is said in the pull request, I am not really familiar with Linux, my current project is my first real touchpoint with Linux...

Thank you for your feedback.

@Drexel2k
Copy link
Author

Drexel2k commented Dec 23, 2023

Ok I checked now, with --no-daemon I see journal entries with journalctl. I think I wasn't aware how to use the journal, thank you. So I think the issue was a non issue. :)

Only for information:
I don't know if it is an issue, but if I use spotifyd.service file as initially posted without the --no-daemon flag, this is the output and there is no spotifyd process living:

Dec 23 01:49:40 raspifm spotifyd[1948]: Loading config from "/etc/spotifyd.conf"
Dec 23 01:49:40 raspifm spotifyd[1948]: No username specified. Checking username_cmd
Dec 23 01:49:40 raspifm spotifyd[1948]: No username_cmd specified
Dec 23 01:49:40 raspifm spotifyd[1948]: No password specified. Checking password_cmd
Dec 23 01:49:40 raspifm spotifyd[1948]: No password_cmd specified
Dec 23 01:49:40 raspifm spotifyd[1948]: No proxy specified
Dec 23 01:49:40 raspifm spotifyd[1948]: Daemonizing running instance
Dec 23 01:49:40 raspifm spotifyd[1950]: Detached from shell, now running in background.
Dec 23 01:49:40 raspifm spotifyd[1950]: Using software volume controller.
Dec 23 01:49:40 raspifm spotifyd[1950]: no usable credentials found, enabling discovery
Dec 23 01:49:40 raspifm systemd[1]: spotifyd.service: Deactivated successfully.

I understood that I should use it with --no-daemon in systemd service and only without on the command line. On the command line it workd without the --no-daemon flag, there I see also the forked process with ps aux | grep spot

@eladyn
Copy link
Member

eladyn commented Dec 23, 2023

That's good to know. I suspect, this might be a systemd thing then and they might be killing everything, when the parent process dies? A fix for this would probably be to set Type=forking or something similar in the .service file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A functionality or parts of a program that do not work as intended
Projects
None yet
Development

No branches or pull requests

2 participants