A server implementation for Harmony, the ComputerCraft audio streaming service.
The following installation guide is written with arch linux in mind, please look up how to install these programs for your own distro.
Git
$ sudo pacman -S git
The Rust toolchain
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Setup the toolchain
$ rustup default stable
PostgreSQL
$ sudo pacman -S postgresql
Diesel
$ cargo install diesel_cli --no-default-features --features postgres
FFmpeg
$ sudo pacman -S ffmpeg
yt-dlp
$ sudo pacman -S yt-dlp
Switch to the postgresql user that the database provided
$ sudo su postgres
Initialize the database
$ initdb -D /var/lib/postgres/data
Start postgresql
$ sudo systemctl enable --now postgresql.service
Create a PostgreSQL user (remember the credentials)
$ createuser --interactive
Create a database for harmony which the new user can access
$ createdb harmony -O database-username
Switch back to your user
$ su your_user
Clone this repo using git
$ git clone [repo_url]
Change into the harmony-data directory
$ cd ./harmony-server/harmony-data
Setup the database with the diesel cli
$ sudo ~/.cargo/bin/diesel migration run --database-url postgres://[user_you_created]:[user_password]@localhost/harmony
Go to the root project folder
$ cd ..
Create and edit the .env file
$ nano .env
The .env file should contain the following:
# Database
DATABASE_URL=postgres://[user_you_created]:[user_password]@localhost/harmony # Never share this with anyone!
# Audio files
MAX_DOWNLOAD_FILESIZE=10M
DOWNLOAD_DIRECTORY=./temp # Make sure these folders exist on your system
SONG_DIRECTORY=./audio # Make sure these folders exist on your system
# Audio stream
STREAM_LIFETIME=10 # Determines how long a stream lives in seconds after no requests have been made to it
# JWT
JWT_SECRET=[A secret token generated by https://jwtsecret.com/ # Never share this with anyone!
JWT_TIME_VALID=[Time in seconds before a login session expires]
Replace [] with the values, then exit nano by pressing ctrl + x
and then y
.
You are now ready to start the server! Simply run the server with
$ cargo run --release