Plexamp service RPI headless not working anymore

Hello
something wrong happened, plexamp service is down and cannot restart it.
I’ve made a clean install with the script, everything went right but after token claim written, i reboot and impossible to start plexamp service:

What’s wrong?

Here the prompt dialogs for manually start and auto start:

root@raspberrypi:/# node /home/pi/plexamp/js/index.js internal/modules/cjs/loader.js:818
throw err;
^

Error: Cannot find module ‘/home/pi/plexamp/js/index.js’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack:
}

Or when i enable the service:

root@raspberrypi:/# systemctl --user enable plexamp.service && systemctl --user start plexamp.service
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=@.host --user to connect to bus of other user)

News:
i identify mistake: plexamp folder was renamed to plexamp.last after trying to update to beta (./plexamp/upgrade.sh -beta) which failed.

I renamed back to original name and it works now.

“node /home/pi/plexamp/js/index.js” is working but not the “systemctl --user enable plexamp.service && systemctl --user start plexamp.service” after sudo -i

Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=@.host --user to connect to bus of other user)

What’s wrong? :frowning:

ps: i installed the latest beta version: https://plexamp.plex.tv/headless/Plexamp-Linux-headless-v4.3.1-beta.7.tar.bz2

What’s your reasoning for using:

sudo -i

rather than using sudo as necessary?
As for

systemctl --user

Where did you copy plexamp.service to?

Have you read Future of Plexamp on Raspberry Pi? - #161 by elan ?

Have you extracted the archive to /home/pi/plexamp or /root/plexamp?

Hello,
thanks for helping me. Yes i read Elan post.

What i did exactly:
1 - I format32 SD card
2 - I installed Raspberry OS 64bits light and connect SSH via puTTy
3 - sudo -i (as mentionned in the readme.md plexamp installer github page)
4 - run the script install
5 - wget the beta file in /home/pi dir
6 - tar -xf the beta file from /home/pi dir
7 - node /home/pi/plexamp/js/index.js (Starting Plexamp 4.3.1-beta.7 prompted)
8 - enter the claim token
9 - systemctl --user enable plexamp.service && systemctl --user start plexamp.service
10 - error: Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined

ps: i also run Elan post commands, no error prompted but the service is not started
$ sudo cp plexamp.service /lib/systemd/system/
$ sudo systemctl daemon-reload
$ sudo systemctl enable plexamp
$ sudo systemctl start plexamp

regarding upgrade.sh not working, you probably need to install jq first (it’s not there by default on Raspberry Pi OS Lite, and it’s needed to produce a usable download link for the plexamp archive)

for the systemd service issues …

your initial install set up a --user service in /home/pi/.config/systemd/plexamp.service, but you’re trying to enable/start it while running as root … and while troubleshooting it looks like you also set up another system service in /lib/systemd/system/plexamp.service

first, look to make sure the /home/pi/.config/systemd/plexamp.service file is still there with contents as expected

then, get rid of the duplicate system service …
$ sudo systemctl stop plexamp
$ sudo systemctl disable plexamp
$ sudo systemctl daemon-reload
$ sudo rm /lib/systemd/system/plexamp.service

now, login as your pi user (not root) and re-enable the --user service …
$ systemctl --user daemon-reload
$ systemctl --user enable plexamp.service
$ systemctl --user start plexamp.service

thanks for your help.

I fact, i don’t find /home/pi/.config/systemd/plexamp.service
But here yes: /home/pi/.config/systemd/user/plexamp.service
That’s the content:

[Unit]
Description=Plexamp
After=network-online.target
Requires=network-online.target

[Service]
Type=simple
WorkingDirectory=/home/pi/plexamp
ExecStart=/usr/bin/node /home/pi/plexamp/js/index.js
Restart=on-failure

[Install]
WantedBy=basic.target

I get rid of the duplicate, i login pi, i can enable but not start:

pi@plexamp:~ $ systemctl --user start plexamp.service
Failed to start plexamp.service: Unit network-online.target not found.

What is network-online.target?

:frowning:

interesting … this user service file worked for you previously?

network-online.target is a system service … apparently a user service can’t depend on the status of a system service (?)

ok, so now I’ll recommend the opposite approach (sorry) …

get rid of the user service …
$ systemctl --user stop plexamp.service
$ systemctl --user disable plexamp.service
$ systemctl --user daemon-reload

create/enable a system service …
$ sudo cp /home/pi/.config/systemd/user/plexamp.service /lib/systemd/system/
$ sudo systemctl daemon-reload
$ sudo systemctl enable plexamp.service
$ sudo systemctl start plexamp.service

I don’t know if it was working with this user file.
I just followed the readme.cmd and i did all the commands in root user (sudo -i).
After i extract beta file and node command, always in root privilege.

I wrote your lines,
get rif of → no error
create/enable → no error

RPi ip = http://192.168.1.51:32500/
But i cannot reach it, seems the service is not running!?

pi@plexamp:~ $ sudo systemctl status
● plexamp
    State: degraded
     Jobs: 0 queued
   Failed: 1 units
    Since: Thu 1970-01-01 01:00:01 CET; 52 years 7 months ago
   CGroup: /
           ├─user.slice
           │ └─user-1000.slice
           │   ├─user@1000.service …
           │   │ └─init.scope
           │   │   ├─536 /lib/systemd/systemd --user
           │   │   └─541 (sd-pam)
           │   ├─session-2.scope
           │   │ ├─665 /bin/login -f
           │   │ └─672 -bash
           │   └─session-3.scope
           │     ├─ 924 sshd: pi [priv]
           │     ├─ 942 sshd: pi@pts/0
           │     ├─ 943 -bash
           │     ├─1490 sudo systemctl status
           │     ├─1491 systemctl status
           │     └─1492 less
           ├─init.scope
           │ └─1 /sbin/init
           └─system.slice
             ├─systemd-udevd.service
             │ └─171 /lib/systemd/systemd-udevd
             ├─triggerhappy.service
             │ └─438 /usr/sbin/thd --triggers /etc/triggerhappy/triggers.d/ --s>
             ├─cron.service
             │ └─377 /usr/sbin/cron -f
             ├─bluetooth.service
             │ └─589 /usr/libexec/bluetooth/bluetoothd
             ├─wpa_supplicant.service
             │ └─444 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
             ├─systemd-journald.service
             │ └─138 /lib/systemd/systemd-journald
             ├─ssh.service
             │ └─526 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
             ├─hciuart.service
             │ └─575 /usr/bin/hciattach /dev/serial1 bcm43xx 3000000 flow -
             ├─rsyslog.service
             │ └─426 /usr/sbin/rsyslogd -n -iNONE
             ├─dhcpcd.service
             │ ├─550 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.con>
             │ └─660 /usr/sbin/dhcpcd -w -q
             ├─rng-tools-debian.service
             │ └─485 /usr/sbin/rngd -r /dev/hwrng
             ├─dbus.service
             │ └─378 /usr/bin/dbus-daemon --system --address=systemd: --nofork >
             ├─systemd-timesyncd.service
             │ └─885 /lib/systemd/systemd-timesyncd
             ├─avahi-daemon.service
             │ ├─374 avahi-daemon: running [plexamp.local]
             │ └─389 avahi-daemon: chroot helper
             └─systemd-logind.service
               └─436 /lib/systemd/systemd-logind
lines 35-57/57 (END)
             │ └─444 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
             ├─systemd-journald.service
             │ └─138 /lib/systemd/systemd-journald
             ├─ssh.service
             │ └─526 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
             ├─hciuart.service
             │ └─575 /usr/bin/hciattach /dev/serial1 bcm43xx 3000000 flow -
             ├─rsyslog.service
             │ └─426 /usr/sbin/rsyslogd -n -iNONE
             ├─dhcpcd.service
             │ ├─550 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0
             │ └─660 /usr/sbin/dhcpcd -w -q
             ├─rng-tools-debian.service
             │ └─485 /usr/sbin/rngd -r /dev/hwrng
             ├─dbus.service
             │ └─378 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --s>
             ├─systemd-timesyncd.service
             │ └─885 /lib/systemd/systemd-timesyncd
             ├─avahi-daemon.service
             │ ├─374 avahi-daemon: running [plexamp.local]
             │ └─389 avahi-daemon: chroot helper
             └─systemd-logind.service
               └─436 /lib/systemd/systemd-logind
lines 35-57/57 (END)

what is the output from executing the following command …

$ sudo systemctl status plexamp.service

pi@plexamp:~ $ sudo systemctl status plexamp.service
● plexamp.service - Plexamp
     Loaded: loaded (/lib/systemd/system/plexamp.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-08-25 17:30:29 CEST; 28min ago
    Process: 1311 ExecStart=/usr/bin/node /home/pi/plexamp/js/index.js (code=exited, status=1/FAILURE)
   Main PID: 1311 (code=exited, status=1/FAILURE)
        CPU: 1.253s

Aug 25 17:30:29 plexamp systemd[1]: plexamp.service: Scheduled restart job, restart counter is at 5.
Aug 25 17:30:29 plexamp systemd[1]: Stopped Plexamp.
Aug 25 17:30:29 plexamp systemd[1]: plexamp.service: Consumed 1.253s CPU time.
Aug 25 17:30:29 plexamp systemd[1]: plexamp.service: Start request repeated too quickly.
Aug 25 17:30:29 plexamp systemd[1]: plexamp.service: Failed with result 'exit-code'.
Aug 25 17:30:29 plexamp systemd[1]: Failed to start Plexamp.

Ok I think we’re getting there …

Look at what’s in the service file
$ more /lib/systemd/system/ plexamp.service

If you see root listed anywhere instead your user pi, then edit the file to replace root with pi …

$ sudo nano /lib/systemd/system/plexamp.service

Ctrl-x to confirm/save the file

$ sudo systemctl daemon-reload
$ sudo systemctl restart plexamp

No root listed :frowning:

pi@plexamp:~ $ more /lib/systemd/system/plexamp.service
[Unit]
Description=Plexamp
After=network-online.target
Requires=network-online.target

[Service]
Type=simple
WorkingDirectory=/home/pi/plexamp
ExecStart=/usr/bin/node /home/pi/plexamp/js/index.js
Restart=on-failure

[Install]
WantedBy=basic.target

I’m typing on a phone and going on memory here, but isn’t there supposed to be a line after “Simple” that says …

User=pi

or something like that?

1 Like

Oh yes, you found the issue :slight_smile:
It was missing this line ‘User=pi’, i don’t know why!?

So i’ve just added it and start the service and it works :slight_smile:

Thanks very much

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.