Multiple instances off the same mopidy server

Hello
I am trying to get 2 modipy instances of the same PI mopidy server.
I have a first server that delivers MUSIC files from an external hard drive on the port 6680 and I use Iris to interact. All is well.
On the same external hard drive I have a folder that holds audio SFX files.

I read the link below about setting up different instances off the same machine.

Sadly, the above discussion does not confirm that the system functions, but it looks promising. But … it does not work for me.

Firstly, when I restart the mopidy service, mopidy does not seem take into consideration the modification I made to the conf file in init.d

admin@pimusic:~ $ sudo systemctl status mopidy
* mopidy.service - Mopidy music server
   Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2021-08-25 17:24:58 CEST; 3s ago
  Process: 1186 ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS)
  Process: 1187 ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS)
 Main PID: 1188 (mopidy)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/mopidy.service
           `-1188 /usr/bin/python3 /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Aug 25 17:25:00 pimusic mopidy[1188]: ModuleNotFoundError: No module named 'mem'
Aug 25 17:25:00 pimusic mopidy[1188]: INFO     [MainThread] mopidy.config Loading config from builtin defaults
Aug 25 17:25:00 pimusic mopidy[1188]: INFO     [MainThread] mopidy.config Loading config from file:///usr/share/mopidy/conf.d/mopidy.conf
Aug 25 17:25:00 pimusic mopidy[1188]: INFO     [MainThread] mopidy.config Loading config from file:///etc/mopidy/mopidy.conf
Aug 25 17:25:00 pimusic mopidy[1188]: INFO     [MainThread] mopidy.config Loading config from command line options
Aug 25 17:25:00 pimusic mopidy[1188]: WARNING  [MainThread] mopidy.config Ignoring config section 'moped' because no matching extension was foun
Aug 25 17:25:00 pimusic mopidy[1188]: WARNING  [MainThread] mopidy.config Ignoring config section 'musicbox_webclient' because no matching exten
Aug 25 17:25:00 pimusic mopidy[1188]: WARNING  [MainThread] mopidy.config Ignoring config section 'local-images' because no matching extension w
Aug 25 17:25:00 pimusic mopidy[1188]: INFO     [MainThread] mopidy.__main__ Enabled extensions: mpd, local, mobile, iris, http, m3u, file, softw
Aug 25 17:25:00 pimusic mopidy[1188]: INFO     [MainThread] mopidy.__main__ Disabled extensions: spotify

Below is the begining of the init.d/mopidy file. I declare 2 config files CONFIG_FILES=“/usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidySFX.conf”

But I don’t understand how mopidy can manage the 2 configs.

#!/bin/sh

### BEGIN INIT INFO
# Provides:          mopidy
# Required-Start:    $network $remote_fs
# Required-Stop:     $network $remote_fs
# Should-Start:      $named alsa-utils avahi dbus pulseaudio
# Should-Stop:       $named alsa-utils avahi dbus pulseaudio
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Mopidy music server
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Mopidy music server"
NAME=mopidy
DAEMON=/usr/bin/mopidy
DAEMON_USER=mopidy
DAEMON_GROUP=audio
CONFIG_FILES="/usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidySFX.conf"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x $DAEMON ] || exit 0

# Read configuration variable file if present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
. /lib/lsb/init-functions

do_start()
{
    if [ ! -d /var/cache/mopidy ]; then
        mkdir -p /var/cache/mopidy
        chown mopidy:audio /var/cache/mopidy
    fi

    start-stop-daemon --start --quiet --name $NAME --pidfile $PIDFILE \

In the startup log above , mopidySFX.conf is not shown and in Iris, I cannot connect to mopidySFX.

Lastly, I have set the mopidySFX config to deliver on port 6681 on http section. Can mopidy serve 2 different channels on 2 seperate ports?

Any thoughts are most welcome.
Thank you

I think you need to consider that thread is from 2015. That said, the linked post from Jodal contains info that is still pretty relevent. Except init.d is long gone (or as good as) and I’m not interested in looking at that. You need to be editing the systemd service files for this to work, not init.d scripts.

I think you’ll find more useful content in the far more recent thread at Multiple Mopidy Instances/SoundCards | One Server - #8 by Cephas1029

Yup … looks like you have been there before on this one. I will try your method. Fingers crossed.
Thank you

Hello,
I followed your instructions but I am getting the strange status report below and I was wondering if you have an idea what it means.

admin@pimusic:~ $ sudo systemctl start mopidySFX
admin@pimusic:~ $ sudo systemctl status mopidySFX
* mopidySFX.service - LSB: Mopidy music server
   Loaded: loaded (/etc/init.d/mopidySFX; generated)
   Active: active (running) since Thu 2021-08-26 08:38:33 CEST; 20min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 30 (limit: 4915)
   CGroup: /system.slice/mopidySFX.service
           `-654 /usr/bin/python3 /usr/bin/mopidy --quiet --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Aug 26 08:55:20 pimusic sudo[1740]: pam_unix(sudo:session): session closed for user root
Aug 26 08:55:24 pimusic sudo[1767]:   mopidy : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/local/lib/python3.7/dist-packages/mopidy_iris/system.sh check
Aug 26 08:55:24 pimusic sudo[1767]: pam_unix(sudo:session): session opened for user root by (uid=0)
Aug 26 08:55:24 pimusic sudo[1767]: pam_unix(sudo:session): session closed for user root
Aug 26 08:55:24 pimusic sudo[1769]:   mopidy : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/local/lib/python3.7/dist-packages/mopidy_iris/system.sh restart
Aug 26 08:55:24 pimusic sudo[1769]: pam_unix(sudo:session): session opened for user root by (uid=0)
Aug 26 08:55:24 pimusic sudo[1771]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/service mopidy restart
Aug 26 08:55:24 pimusic sudo[1771]: pam_unix(sudo:session): session opened for user root by (uid=0)
Aug 26 08:55:24 pimusic sudo[1771]: pam_unix(sudo:session): session closed for user root
Aug 26 08:55:24 pimusic sudo[1769]: pam_unix(sudo:session): session closed for user root

By comparison, the standard mopidy instance status below

admin@pimusic:~ $ sudo systemctl start mopidy   
admin@pimusic:~ $ sudo systemctl status mopidy
* mopidy.service - Mopidy music server
   Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-08-26 08:55:24 CEST; 11min ago
 Main PID: 1778 (mopidy)
    Tasks: 10 (limit: 4915)
   CGroup: /system.slice/mopidy.service
           `-1778 /usr/bin/python3 /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Aug 26 08:55:26 pimusic mopidy[1778]: INFO     [MainThread] mopidy.commands Starting Mopidy backends: FileBackend, M3UBackend, StreamBackend, LocalBackend
Aug 26 08:55:26 pimusic mopidy[1778]: INFO     [Audio-2] mopidy.audio.actor Audio output set to "audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! filesink location=/t
Aug 26 08:55:26 pimusic mopidy[1778]: INFO     [MainThread] mopidy.commands Starting Mopidy core
Aug 26 08:55:26 pimusic mopidy[1778]: INFO     [Core-7] mopidy.core.actor Loading state from /var/lib/mopidy/core/state.json.gz
Aug 26 08:55:26 pimusic mopidy[1778]: INFO     [MainThread] mopidy.commands Starting Mopidy frontends: HttpFrontend, MpdFrontend, ScrobblerFrontend, IrisFrontend
Aug 26 08:55:26 pimusic mopidy[1778]: ERROR    [MainThread] mopidy.commands Frontend (HttpFrontend) initialization error: HTTP server startup failed: [Errno 98] Address already in use
Aug 26 08:55:26 pimusic mopidy[1778]: ERROR    [MainThread] mopidy.commands Frontend (MpdFrontend) initialization error: MPD server startup failed: [Errno 98] Address already in use
Aug 26 08:55:26 pimusic mopidy[1778]: INFO     [IrisFrontend-9] mopidy_iris.core Starting Iris 3.58.1
Aug 26 08:55:26 pimusic mopidy[1778]: INFO     [MainThread] mopidy.commands Starting GLib mainloop
Aug 26 08:55:27 pimusic mopidy[1778]: ERROR    [ScrobblerFrontend-8] mopidy_scrobbler.frontend Error during Last.fm setup: Authentication Failed - You do not have permissions to access the service

I think i was having general permissions issues … but now when I start the 2nd service, I get the status below. I cannot find anything on the web that explains what LSB is.

Strangely, the /etc/init.d file is loaded. Is this right or should I junk it?
Many thanks

admin@pimusic:~ $ sudo systemctl status mopidySFX
* mopidySFX.service - LSB: Mopidy music server
   Loaded: loaded (/etc/init.d/mopidySFX; generated)
   Active: active (running) since Mon 2021-08-30 11:32:44 CEST; 7min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 634 ExecStart=/etc/init.d/mopidySFX start (code=exited, status=0/SUCC
    Tasks: 14 (limit: 4915)
   CGroup: /system.slice/mopidySFX.service
           `-663 /usr/bin/python3 /usr/bin/mopidy --quiet --config /usr/share/mo

Aug 30 11:32:44 pimusic systemd[1]: Starting LSB: Mopidy music server...
Aug 30 11:32:44 pimusic systemd[1]: Started LSB: Mopidy music server.

I deleted the

/etc/init.d/mopidySFX

and now I get the below

admin@pimusic:~ $ sudo systemctl start mopidySFX
[sudo] password for admin: 
Failed to start mopidySFX.service: Unit mopidySFX.service not found.

I think that I have done as you suggested in the mopidy.service file

[Unit]
Description=Mopidy music server
After=avahi-daemon.service
After=dbus.service
After=network-online.target
Wants=network-online.target
After=nss-lookup.target
After=pulseaudio.service
After=remote-fs.target
After=sound.target

[Service]
User=mopidy
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/cache/mopidy
ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy
ExecStart=/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidySFX.conf

[Install]
WantedBy=multi-user.target

the /etc/mopidy/mopidySFX.conf exists but has only the elements as per your example.

But I have found that having the line below with the 2 confs in the /lib/systemd/system/mopidy.service file breaks the server.

ExecStart=/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidySFX.conf

Any thoughts on how to troubleshoot this?
Many thanks

I can confirm that by following most of the above but essentially duplicating 2 config instances of mopidy plus having both instances start seperately in the terminal, I can access the 2 databases off the same raspberry PI using Iris.
Iris has the ability to consult numerous databases in the same settings interface. That does not work for me but using the 2 ports in the URL in seperate web browser pages, accesses the 2 instances.
The only problem is that snapcast cannot play 2 files cleanly at the same time, but that is not a problem for me.

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