Mopidy as service crashes and is missing iris extension

Hi,
i am running mopidy on a raspberry.
I installed it using the following commands from (New users can only post 2 links)

wget -q -O - (New users can only post 2 links) | sudo apt-key add -
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list apt.mopidy.com/jessie.list
sudo apt-get update
sudo apt-get install mopidy

Then i installed iris:

pip install Mopidy-Iris

Then i installed the spotify extension:

sudo apt-get install mopidy-spotify

then i installed the MQTT extension:
from here
(New users can only post 2 links)

cd ~
git clone /magcode/mopidy-mqtt.git
cd mopidy-mqtt
sudo python setup.py develop

Then i edited the config under

~/.config/mopidy/mopidy.conf

Enabled HTTP, did the configs for spotify and MQTTHook as well as iris.
Then i started mopidy with

mopidy

Everything works good: Iris is there, spotify is connected, music comes out of the box, mqtt addon also working.

Now i tried to install it as service, and everything starts to fail.

I did the following:
From (New users can only post 2 links)

Copied the config from ~/.config/mopidy/mopidy.conf
to /etc/mopidy/mopidy.conf

Then started the service:

sudo systemctl enable mopidy
sudo systemctl start mopidy

So far so good. After a while when i check

sudo service mopidy status

It gives me this:

● mopidy.service - Mopidy music server
Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-01-28 19:57:19 UTC; 11min ago
Process: 18616 ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS)
Process: 18613 ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS)
Main PID: 18620 (mopidy)
CGroup: /system.slice/mopidy.service
└─18620 /usr/bin/python /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Jan 28 19:57:40 raspberrypi mopidy[18620]: INFO Starting Mopidy frontends: MQTTFrontend, MpdFrontend, HttpFronten
Jan 28 19:57:40 raspberrypi mopidy[18620]: INFO mopidy_mqtt initializing …
Jan 28 19:57:40 raspberrypi mopidy[18620]: INFO MPD server running at [::ffff:127.0.0.1]:6600
Jan 28 19:57:40 raspberrypi mopidy[18620]: INFO HTTP server running at [::ffff:192.168.0.39]:6680
Jan 28 19:57:40 raspberrypi mopidy[18620]: INFO Starting GLib mainloop
Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO Connected with result code 0
Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO Subscribed to home/livingroom/music/play
Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO sub:home/livingroom/music/control
Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO sub:home/livingroom/music/volume
Jan 28 19:57:42 raspberrypi mopidy[18620]: INFO Logged in to Spotify in online mode

Looks good so far.
But when i access mopidy via WEB, there is no iris:
image
Remember: it was there when running mopidy just with “mopidy” command.

And when i try to start a playlist (via MQTTHook extension, which worked well as well before):

● mopidy.service - Mopidy music server
Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-01-28 20:11:32 UTC; 11s ago
Process: 18620 ExecStart=/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf (code=exited, st
Process: 18616 ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS)
Process: 18613 ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS)
Main PID: 18620 (code=exited, status=255)

Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO Connected with result code 0
Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO Subscribed to home/livingroom/music/play
Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO sub:home/livingroom/music/control
Jan 28 19:57:41 raspberrypi mopidy[18620]: INFO sub:home/livingroom/music/volume
Jan 28 19:57:42 raspberrypi mopidy[18620]: INFO Logged in to Spotify in online mode
Jan 28 20:11:25 raspberrypi mopidy[18620]: INFO received a message on home/livingroom/music/play with payload spo
Jan 28 20:11:32 raspberrypi mopidy[18620]: * failed to open vchiq instance
Jan 28 20:11:32 raspberrypi systemd[1]: mopidy.service: Main process exited, code=exited, status=255/n/a
Jan 28 20:11:32 raspberrypi systemd[1]: mopidy.service: Unit entered failed state.
Jan 28 20:11:32 raspberrypi systemd[1]: mopidy.service: Failed with result ‘exit-code’.

So as soon as it has to play music it crashes.

What am i doing wrong? Why is iris not there and why does it fail?
Did i follow the wrong tutorials?

Greetings

The service cannot see extensions that were installed in your users home directory which is where pip now defaults to using. You must run sudo pip install mopidy-iris.

As for the crashing, I think that’s because in the latest raspbian you also need the mopidy user (used when running Mopidy as a service) to be a member of the video group in order to access the hdmi port (which I’m guessing you are doing).

Thank you for your answer! Will try that “pip” with “sudo”.
I am using the headphone jack, but when googling for “failed to open vchiq instance” they said something similar to you on another product. Maybe i am missing a config entry to set it to the headphone jack (did not copy the whole config, just the parts i changed), or it needs to access HDMI at all times?

can i set mopidy as some kind of “Administrator” so i will not run into problems like this?

Giving the Mopidy user the correct permission is the correct solution. Running it as root user is an unnecessary hack. But it’s your system, of course!

I don’t recall which output Raspbian currently defaults to but if you look at the raspberry pi specific install instructions in our documentation, it does mention how to switch between the two.

Thanks a lot for that information, everything working now :slight_smile:
added “mopidy” users to the “sudoers” file

Just to to be really clear to anyone else that ends up here, that workaround is definitely not recommended. Fixing the permissions properly is the answer.