Skip to content

unipv-ce18/harmony

Repository files navigation

Harmony
A questionable Music Library made by questionable engineers...

License CircleCI Code Climate maintainability

Spin it up

Backend

With Docker

  • Install Docker and Docker Compose;
  • Go inside the docker directory and run ./make_worker_image.sh (or make_worker_image.cmd on Windows) to create the transcoder microservice image.

Now, each time you want to start the backend, run:

# docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d

To stop it (add -v at the end to also remove all the data):

# docker-compose -f docker-compose.yml -f docker-compose.dev.yml down

Inside an IntelliJ IDE, you can also use the "Docker dev stack" run configuration

Backend services are now available at the following locations:
Where What
http://localhost/ Service API and API Explorer
http://localhost:1234/ MongoDB Admin
http://localhost:9000/ Minio Web interface, credentials in docker-compose.dev.yml
http://localhost:15672/ RabbitMQ management, credentials guest:guest

You can also access MongoDB with an alternative client at localhost:27017 and load the OpenAPI specification at http://localhost/api/v1/spec in your REST client of choice.

If you are using Docker for Windows with the WSL 2 backend there is a known issue with Windows HNS reserving random ports on start and preventing the services from booting properly.

Run netsh int ipv4 set dynamic tcp start=49152 num=1638 for saner defaults or reg add HKLM\SYSTEM\CurrentControlSet\Services\hns\State /v EnableExcludedPortRange /d 0 /f for disabling port reservation completely.

Using Python directly

You need to run your own instances of MinIO, RabbitMQ and MongoDB. Look at docker/rabbitmq/definitions.json and docker/mongo.init.d/ for definitions and scripts to kickstart your environment.

MinIO guide.

Get MinIO:

$ wget https://dl.min.io/server/minio/release/linux-amd64/minio
$ chmod +x minio

Get mc:

$ wget https://dl.min.io/client/mc/release/linux-amd64/mc
$ chmod +x mc

Configure client:

$ ./mc config host add minio http://127.0.0.1 HVTH67YJMJ3BVSHPWJOM kAeWXU3qV5vyofP3kTnyEmtp1BarIvE4CrQIF6wU --api S3v4
$ ./mc config host add local http://localhost HVTH67YJMJ3BVSHPWJOM kAeWXU3qV5vyofP3kTnyEmtp1BarIvE4CrQIF6wU --api S3v4

Run MinIO server:

$ sudo ./minio server /data

Enable webhooks notification:

$ ./mc admin config set local/ notify_webhook:_ endpoint="http://localhost/_webhooks/s3/events" auth_token="ivitelloniinbouvette"
$ ./mc admin service restart local/
$ ./mc event add local/lossless-songs arn:minio:sqs::_:webhook --event put
$ ./mc event list local/lossless-songs
$ ./mc event add local/images arn:minio:sqs::_:webhook --event put
$ ./mc event list local/images

Install the requirements for the components you need:

$ cd backend
$ python -m venv venv
$ . venv/bin/activate
$ pip install -r apiserver/requirements.txt
$ pip install -r director/requirements.txt
$ pip install -r worker/requirements.txt

Then run the microservices:

$ python -m apiserver &
$ python -m director &

The director will start any worker as needed.

Web App

We built our UI using Preact. To run it, arm yourself with Node.js and Yarn, then do the usual startup sequence:

$ cd webapp
$ yarn install
$ yarn start

Wait some moments for it to build everything, then you can go at http://localhost:8080 and start playing around.

You can create users using the API Explorer embedded in the backend.

Adding some beats

Harmony stores lossless FLAC songs and transcodes them on-demand; so you need your music in .flac to be able to import it.

With the backend running, start backend/hyadm_add_songs.py with argument a folder containing your songs.

To fetch additional metadata from Last.fm and MusicBrainz while importing, put LASTFM_API_KEY=**your api key** inside a new local environment file for the backend at backend/.env.

About

A free and open source Music Streaming platform (Software Engineering project)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6