Skip to content

Run and debug

This page helps you start the server from your checkout and find out what it does. It assumes you finished Set up your environment.

  • VS Code: pick Music Assistant: Server under Run and Debug and press F5.
  • Command line: with .venv active, run python -m music_assistant --log-level debug.

Open http://localhost:8095 for the web interface. Stop the server with Ctrl+C.

Option Default What it does
--data-dir ~/.musicassistant, or $XDG_DATA_HOME/music-assistant Folder for the settings, the databases and the log.
--cache-dir .cache in the data folder, or $XDG_CACHE_HOME/music-assistant Folder for the cache database and the thumbnails.
--log-level info, or the LOG_LEVEL variable critical, error, warning, info, debug or verbose (more than debug).
--safe-mode off, or on with MASS_SAFE_MODE=1 Loads the core controllers and the built-in providers only: no other providers and no community catalog. Use it when a provider breaks the start.
--dev-providers-dir none Loads providers from a folder outside the server, see Test your change.

Every provider and core controller also has an advanced Log level setting. Set it to debug or verbose to see more of one part without the noise of the rest.

Give the development server a data folder of its own, so a broken migration or a test setting never touches the data you care about:

Terminal window
python -m music_assistant --log-level debug --data-dir ~/music-assistant-dev

When XDG_CACHE_HOME is set, pass --cache-dir too, because the cache folder then does not follow the data folder.

  • A new data folder sets up the player providers that are on by default, such as AirPlay, Chromecast and DLNA, so the development server finds the speakers on your network.
  • Two servers on one machine want the same ports, such as 8095 and 8097. Stop the other one first.

The VS Code launch configuration sets PYTHONDEVMODE=1. From the command line:

Terminal window
PYTHONDEVMODE=1 python -m music_assistant --log-level debug

It turns on:

  • asyncio debug mode: a warning for every callback that holds the event loop for more than 100 ms, and the place where a task was created in the log of its unhandled error;
  • a warning for every database query that takes longer than half a second;
  • the dev mode of the server, which loads the demo providers (the folders starting with _) and providers from --dev-providers-dir.

Use the variable, not python -X dev: the server reads the variable for the last two. Expect a slower server, as asyncio then records a stack for every scheduled callback. A checkout with .venv at its root always runs in the dev mode of the server, also without the variable.

The data folder holds musicassistant.log, settings.json and the databases library.db, auth.db and audio_analysis.db; cache.db is in the cache folder. The log starts anew at every start of the server and at 10 MB; the previous one is musicassistant.log.1. Where data lives explains every file.

Read a database with SELECT only, and open it read-only:

Terminal window
sqlite3 -readonly ~/music-assistant-dev/library.db "SELECT COUNT(*) FROM tracks;"

Never write to the database of a running server.

The diagnostics report is what users attach to a bug report, see Report a bug well. It holds system information, a count of providers, players and library items, recent errors, and a section per controller or provider that adds one, with personal data removed. The API command is diagnostics/get.

To add a section for your provider, override get_diagnostics() on it. Return a small JSON-safe dict without secrets; a section that takes longer than 2 seconds is left out.

The Profiler plugin (profiler) measures a running server, also a user’s, without shell access: CPU profiles, memory growth, event loop lag and asyncio tasks. Add it while you reproduce the problem, download the diagnostics report, which then carries its report, and remove the plugin again. Its README explains how to read the report.

To compare performance before and after a change, use the performance benchmark.

Music Assistant is a project of the Open Home Foundation.