README.md 2.66 KB
Newer Older
Christian Pointner's avatar
Christian Pointner committed
1
2
# Import and Playlist Daemon

Christian Pointner's avatar
Christian Pointner committed
3
Tank implements an AURA import and playlist daemon. Uploads can be normalized
4
5
6
based on the [loudnorm](https://k.ylo.ph/2016/04/04/loudnorm.html) Loudness
Normalization. Resulting files are served to Aura Engine via some configured
directory.
7

David Trattnig's avatar
David Trattnig committed
8
9
10
11
## Requirements

* [Go](https://golang.org/) (v1.12+ recommended)

Christian Pointner's avatar
Christian Pointner committed
12
## Quickstart
13
14
15
16
17
18
19

To install tank, use the `go get` command:

```sh
$ go get gitlab.servus.at/autoradio/tank/...
```

20
Create configuration file see:
21
https://gitlab.servus.at/autoradio/tank/blob/master/contrib/sample-cfg.yaml
22

23
Make sure that the directory pointed to by `store.path` exists and is writeable
24
25
for the user running the daemon, and a Postgres database is present and set up
according to the configuration.
26

27
28
29
And then run the `tank` binary:

```sh
30
$ $GOPATH/bin/tank --config config.yaml run --listen localhost:8040
31
```
Christian Pointner's avatar
Christian Pointner committed
32
33
34
35
36
37

## Development

Check out the repository and build the daemon:

```sh
Christian Pointner's avatar
Christian Pointner committed
38
$ git clone https://gitlab.servus.at/autoradio/tank
Christian Pointner's avatar
Christian Pointner committed
39
40
$ cd tank
$ make
Christian Pointner's avatar
Christian Pointner committed
41
42
```

43
### Database Setup
Christian Pointner's avatar
Christian Pointner committed
44

45
First, we need to start a Postgres container:
Christian Pointner's avatar
Christian Pointner committed
46
47

```sh
48
$ ./contrib/run_server.sh
Christian Pointner's avatar
Christian Pointner committed
49
50
```

51
52
Wait for the server to boot up and then initialize the database using a second
terminal, initialize the database:
Christian Pointner's avatar
Christian Pointner committed
53
54

```sh
55
56
$ ./contrib/run_client.sh
$$$ psql < init.sql
Christian Pointner's avatar
Christian Pointner committed
57
58
```

59
60
61
62
63
This command can also be used to empty the database if you want to start with a
new one.

After the daemon has applied the initial migrations you may check out the
schema of the database:
Christian Pointner's avatar
Christian Pointner committed
64

Christian Pointner's avatar
Christian Pointner committed
65
```sh
66
$$$ psql < info.sql
Christian Pointner's avatar
Christian Pointner committed
67
```
Christian Pointner's avatar
Christian Pointner committed
68

69
70
71
72
Once you are done with the database you can stop the server by pressing
`CTRL-C` inside the terminal of the server.

Now, you may run the daemon using the following command:
Christian Pointner's avatar
Christian Pointner committed
73
74

```sh
75
$ ./contrib/run.sh
Christian Pointner's avatar
Christian Pointner committed
76
77
```

78
79
This script is using `contrib/sample-cfg.yaml` and depends on a postgres server
running on localhost.
Christian Pointner's avatar
Christian Pointner committed
80

81
82
83
You may use the scripts inside `contrib/` to start docker containers for this purpose.

## Running behind reverse proxies
Christian Pointner's avatar
Christian Pointner committed
84

85
86
87
88
89
For production environments we highly recommend running `tank` behind an
SSL-enabling reverse proxy. If the base path for the api endpoints as well as
the authentication should be hosted under a subdirectory, the reverse proxy
needs to rewrite the request to be based on `/`. For Nginx the following
configuration can be used:
Christian Pointner's avatar
Christian Pointner committed
90
91

```
92
93
94
95
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name aura.example.com;
Christian Pointner's avatar
Christian Pointner committed
96

97
98
    ssl_certificate     /path/to/certificate;
    ssl_certificate_key /path/to/private-key;
Christian Pointner's avatar
Christian Pointner committed
99

100
101
102
103
104
    location /tank/ {
         proxy_buffering off;
         proxy_ignore_headers "X-Accel-Buffering";
         proxy_request_buffering off;
         proxy_http_version 1.1;
Christian Pointner's avatar
Christian Pointner committed
105

106
107
108
109
110
         proxy_pass http://127.0.0.1:8040/;
    }
    ## ... other locations ...
}
```