An open API service indexing awesome lists of open source software.

https://github.com/daxanius/harmony-server

A server implementation for Harmony, the ComputerCraft audio streaming service
https://github.com/daxanius/harmony-server

backend computercraft-tweaked minecraft music rust streaming

Last synced: 12 months ago
JSON representation

A server implementation for Harmony, the ComputerCraft audio streaming service

Awesome Lists containing this project

README

          

# Harmony Server
A server implementation for Harmony, the ComputerCraft audio streaming service.

## Installation
The following installation guide is written with arch linux in mind, please look up how to install these programs for your own distro.

### Install Tools
Git
```sh
$ sudo pacman -S git
```

The Rust toolchain
```sh
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

Setup the toolchain
```sh
$ rustup default stable
```

PostgreSQL
```sh
$ sudo pacman -S postgresql
```

Diesel
```sh
$ cargo install diesel_cli --no-default-features --features postgres
```

FFmpeg
```sh
$ sudo pacman -S ffmpeg
```

yt-dlp
```sh
$ sudo pacman -S yt-dlp
```

### Setup database
Switch to the postgresql user that the database provided
```sh
$ sudo su postgres
```

Initialize the database
```sh
$ initdb -D /var/lib/postgres/data
```

Start postgresql
```sh
$ sudo systemctl enable --now postgresql.service
```

Create a PostgreSQL user (remember the credentials)
```sh
$ createuser --interactive
```

Create a database for harmony which the new user can access
```sh
$ createdb harmony -O database-username
```

Switch back to your user
```sh
$ su your_user
```

### Setup repo
#### Clone Repo
Clone this repo using git
```sh
$ git clone [repo_url]
```

#### Create database schema
Change into the harmony-data directory
```sh
$ cd ./harmony-server/harmony-data
```

Setup the database with the diesel cli
```sh
$ sudo ~/.cargo/bin/diesel migration run --database-url postgres://[user_you_created]:[user_password]@localhost/harmony
```

#### Setup Variables
Go to the root project folder
```sh
$ cd ..
```

Create and edit the .env file
```sh
$ nano .env
```

The .env file should contain the following:
```sh
# 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`.

### Start the server
You are now ready to start the server! Simply run the server with
```sh
$ cargo run --release
```