{"id":17488458,"url":"https://github.com/esteanes/mopidy_multiple-instances","last_synced_at":"2025-03-28T15:42:09.030Z","repository":{"id":216061544,"uuid":"391249014","full_name":"ESteanes/Mopidy_Multiple-Instances","owner":"ESteanes","description":"A guide \u0026 script to create multiple instances of Mopidy and integrate it with Snapcast","archived":false,"fork":false,"pushed_at":"2021-08-22T00:06:35.000Z","size":23,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-19T07:08:03.240Z","etag":null,"topics":["mopidy","snapcast"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ESteanes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-07-31T03:54:48.000Z","updated_at":"2022-10-22T21:39:37.000Z","dependencies_parsed_at":"2024-01-08T09:37:20.359Z","dependency_job_id":null,"html_url":"https://github.com/ESteanes/Mopidy_Multiple-Instances","commit_stats":null,"previous_names":["esteanes/mopidy_multiple-instances"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESteanes%2FMopidy_Multiple-Instances","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESteanes%2FMopidy_Multiple-Instances/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESteanes%2FMopidy_Multiple-Instances/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESteanes%2FMopidy_Multiple-Instances/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ESteanes","download_url":"https://codeload.github.com/ESteanes/Mopidy_Multiple-Instances/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246056661,"owners_count":20716782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mopidy","snapcast"],"created_at":"2024-10-19T04:07:38.311Z","updated_at":"2025-03-28T15:42:09.009Z","avatar_url":"https://github.com/ESteanes.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Making Multiple Mopidy Instances\n\nThis script/instruction detials how to create multiple instances of mopidy which pipe their outputs to separate mopidy streams. \n\nThis enables you to have the flexibility to play one song across multiple speakers or have each speaker play its own song. \n\n### Prerequistes \n\n* Mopidy installed [Mopidy Github](https://github.com/mopidy/mopidy)\n* Snapcast installed [Snapcast Github](https://github.com/badaix/snapcast)\n\n## Automatically\n\n```\n$ wget https://github.com/ESteanes/Mopidy_Multiple-Instances/releases/download/v0.1.0/multiple_mopidy.sh\n$ bash multiple_mopidy.sh -N \u003cnumber of instances\u003e -H \u003chostname\u003e -O snapcast\n```\nNote: leaving the hostname blank will result in 127.0.0.1 which means that mopidy will only listen to local requests. Generally unfavourable setup.\n## Manually\n\n\\\u003cn\u003e represents the number of instances\n\n1. Create additional mopidy_\\\u003cn\u003e.conf files\n```\n$ sudo touch /etc/mopidy/mopidy_\u003cn\u003e.conf\n```\n2. Using a text editor, edit the file you created and add the following information in your mopidy_\\\u003cn\u003e.conf\n```\n[core]\ncache_dir = /var/cache/mopidy_\u003cn\u003e\ndata_dir = /var/lib/mopidy_\u003cn\u003e\n\n[http]\nport = 668\u003cn\u003e\n\n[audio]\noutput = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! filesink location=/tmp/snapfifo_\u003cn\u003e\n```\n3. _Optional_ Adding custom settings\n\nYou may want to add custom information such as spotify accounts to different mopidy instances as that can help with personalisation. Do that in the corresponding file\n\nFor example spotify settings:\n```\n[spotify]\nenabled = true\nusername = youremail@email.com\npassword = your_spotify_password\nclient_id = your_client_id\nclient_secret = your_client_secret\n```\n\n4. Modify the original mopidy.conf file\n\nAdd in all the allowed origins for however many mopidy instances you created. This will allow you to access your 2nd mopidy \n```\n$ nano /etc/mopidy/mopidy.conf\n\nallowed_origins = \u003chostname\u003e:6680,\u003chostname\u003e:668\u003cn\u003e (for all n)\n```\n5. Create and give ownership of cache and data directoires\n\nIf creating multiple directories, can use * wildcard for `chown` command\n```\n$ mkdir /var/cache/mopidy_\u003cn\u003e\n$ mkdir /var/lib/mopidy_\u003cn\u003e\n$ chown mopidy:audio /var/cache/mopidy_\u003cn\u003e /var/lib/mopidy_\u003cn\u003e\n```\n6. Create copies of the mopidyctl script\n\nCreating copies of the mopidyctl script will enable you to run these mopidy instances as a service without having to manually enable them upon reboot.\n\n```\n$ cp /usr/sbin/mopidyctl /usr/sbin/mopidyctl_\u003cn\u003e\n```\nThen inside `usr/sbin/mopidyctl_\u003cn\u003e`, change the `CONFIG_FILES` variable to the following:\n```\nCONFIG_FILES=\"/usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidy_\u003cn\u003e.conf\"\n```\nThis will make sure that the service will utilise the appropriate configuration files\nunique to the extra instances, overwriting that in the base `mopidy.conf` file with the details in `mopidy_\u003cn\u003e.conf` that you altered previously.\n\n7. Creating additional systemd scripts\n\nYou need to create copies of the systemd scripts to activate systemd for all the different instances\n\n```\n$ cp /lib/systemd/system/mopidy.service /lib/systemd/system/mopidy_\u003cn\u003e.service\n```\nThen, using a text editor, edit the `mopidy_\u003cn\u003e.service` file with the following:\n```\nExecStart=/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidy_\u003cn\u003e.conf\n```\n8. Adding additional streams to Snapcast\n\nSince we are creating multiple instances of mopidy, we need to add these filesink locations in the snapcast configuration file that we are referencing in section 2.\n\n```\n$ nano /etc/snapserver.conf\n```\nthen under the `[Stream]` heading, add the following:\n```\nsource = pipe:///tmp/snapfifo_\u003cn\u003e?name=\u003cyour custom name\u003e\n```\nHere you can specify a custom name for each source. You can set up each of the mopidy instances for different people or sections of your house/apartment.\n\n9. Restart all the services\n\nRestart all the services and complete the initialising processes\n```\n$ systemctl restart snapserver.service\n$ mopidyctl_\u003cn\u003e local scan\n$ systemctl enable mopidy*.service\n$ systemctl start mopidy*.service\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festeanes%2Fmopidy_multiple-instances","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Festeanes%2Fmopidy_multiple-instances","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festeanes%2Fmopidy_multiple-instances/lists"}