Skip to content

accentor/api

Repository files navigation

Accentor API

CI codecov

API for Accentor, a modern music server focusing on metadata.

Why use Accentor?

Accentor gives you complete control over your music. You can build your own collection (with good old CD's, bandcamp downloads, ...) in the sound quality that you want and stream it either through the web frontend or android app.

Accentor is focused on metadata. We allow you to add detailed metadata to your music collection, beyond what the tags inside an audio file are capable of. Album and tracks can have multiple artists with a different name on different albums/tracks, albums can have multiple labels and tracks can have multiple genres.

The metadata is completely in your control: you can edit it however you want.

How to deploy

  1. Make sure you have the correct dependencies installed. This is mostly ffmpeg and ruby.

  2. Create a checkout of the code.

  3. Install all ruby dependencies with bundle install.

  4. Setup the database. Only postgresql is supported. Don't forget to run rails db:setup.

  5. Make sure to perform migrations before starting the server. Also run the ffmpeg:check_version rake task.

  6. Run puma -C config/puma.rb to start the server. You can use any other application server as well, but there is no configuration provided.

  7. Run good_job start to start a background worker. In Accentor, all jobs are handled by the following 4 queues:

    • within_30_seconds
    • within_5_minutes
    • within_30_minutes
    • whenever

    These queue names refer to the period in which a job should be picked up by a worker. If you want/need to manage the available workers in more details, you can specify the availability of workers per process or per thread with GOOD_JOB_QUEUES. Check the good job docs for the possibilities.

  8. You probably want to set the following environment variables when running:

    • DATABASE_URL
    • RACK_ENV
    • RAILS_ENV
    • SECRET_KEY_BASE

    You can generate a new SECRET_KEY_BASE using bin/rails secret. For optimal caching, this key should be stable.

    Optionally set the following variables to control where Accentor stores its files:

    • FFMPEG_LOG_LOCATION
    • RAILS_STORAGE_PATH
    • FFMPEG_VERSION_LOCATION
    • RAILS_TRANSCODE_CACHE
    • BOOTSNAP_CACHE_DIR
    • PIDFILE
    • RAILS_LOG_TO_STDOUT
  9. This leaves you with a server running on port 3000. Use a reverse proxy like Apache or nginx to route your traffic. If you are deploying the web frontend an the same subdomain, you can match the requested path on /api and /rails and only proxy those requests.

Local development

To run and develop locally:

  1. Make sure you are running the correct version of ruby.
  2. Install all dependencies with bundle install
  3. Make sure you have postgresql is running and add a role accentor with password accentor (This role should have the permission to login and createdb)
  4. Make sure you have ffmpeg installed, this is needed to calculate file length and convert audio.
  5. Setup the local database with rails db:setup. This will also seed the database with an admin account and some starting points for the application.

Once you've done this, you can always run a local server with rails server

If you use nix on your local machine, you can also use the devShell provided by flake.nix.

Help

Have a question? You can ask it through GitHub discussions or in the Matrix channel.

Think you have noticed a bug or thought of a great feature we can add? Create an issue.