README.md 3.69 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
David Trattnig's avatar
David Trattnig committed
4
5
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.
6

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

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

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

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

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

19
Create configuration file see:
Christian Pointner's avatar
Christian Pointner committed
20
  https://gitlab.servus.at/autoradio/tank/blob/master/contrib/sample-cfg.yaml
21

22
Make sure that the directory pointed to by `store.path` exists and is writeable
23
24
for the user running the daemon

25
26
27
And then run the `tank` binary:

```sh
28
$ $GOPATH/bin/tank --config config.yaml run --listen localhost:8040
29
```
Christian Pointner's avatar
Christian Pointner committed
30

31
### Problem with some versions of MariaDB
32

33
If you start `tank` for the first time using MariaDB you may get the following error message:
34
35
36
37
38

```
running database migrations failed: Error 1071: Specified key was too long; max key length is 767 bytes
```

39
40
This most likely means you are using an older version of MariaDB with the default character-set set to
`utf8mb4`. Please read [contrib/mariadb-stretch-err1071.md](/contrib/mariadb-stretch-err1071.md) for help.
41
42
43
44

If you encouter this problem on any other platform please let us know!


45
46
47
## Running behind reverse proxies

For production environments we highly recommend to run `tank` behind an SSL-enabling reverse proxy.
Christian Pointner's avatar
Christian Pointner committed
48
49
If the base path for the api endpoints as well as the authentication should be hosted under a sub-directory,
the reverse proxy needs to rewrite the request to be based on `/`. For Nginx the following configuration
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
can be used:

```
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name aura.example.com;

    ssl_certificate     /path/to/certificate;
    ssl_certificate_key /path/to/private-key;

    location /tank/ {
         proxy_buffering off;
         proxy_ignore_headers "X-Accel-Buffering";
         proxy_request_buffering off;
         proxy_http_version 1.1;

         proxy_pass http://127.0.0.1:8040/;
    }
    ## ... other locations ...
}
```

Christian Pointner's avatar
Christian Pointner committed
73
74
75
Please mind that the built-in web UI does not work when the base-path is not `/`. Please see !2 for more
details about this.

76

Christian Pointner's avatar
Christian Pointner committed
77
78
79
80
81
## Development

Check out the repository and build the daemon:

```sh
Christian Pointner's avatar
Christian Pointner committed
82
$ git clone https://gitlab.servus.at/autoradio/tank
Christian Pointner's avatar
Christian Pointner committed
83
84
$ cd tank
$ make
Christian Pointner's avatar
Christian Pointner committed
85
86
87
88
89
```

You may run the daemon using the following command:

```sh
Christian Pointner's avatar
Christian Pointner committed
90
$ ./contrib/run.sh
Christian Pointner's avatar
Christian Pointner committed
91
92
```

93
94
This is using `contrib/sample-cfg.yaml` and depends on a mysql or postgres server
running on localhost. You may use the scripts inside `contrib/` to start docker
Christian Pointner's avatar
Christian Pointner committed
95
96
97
98
99
containers for this purpose.

### mysql

```sh
Christian Pointner's avatar
Christian Pointner committed
100
$ ./contrib/mysql/run_server.sh
Christian Pointner's avatar
Christian Pointner committed
101
102
103
104
105
```

Wait for the server to boot up and then initialize the database using a second terminal:

```sh
Christian Pointner's avatar
Christian Pointner committed
106
107
$ ./contrib/mysql/run_client.sh
mysql> source init.sql
Christian Pointner's avatar
Christian Pointner committed
108
109
110
```

This command can also be used to empty the database if you want to start with a new one.
Christian Pointner's avatar
Christian Pointner committed
111
112
After the daemon has ran the initial migrations you may check out the schema of the database:

Christian Pointner's avatar
Christian Pointner committed
113
114
```sh
mysql> source info.sql
Christian Pointner's avatar
Christian Pointner committed
115
```
Christian Pointner's avatar
Christian Pointner committed
116
117
118
119

Once you are done with the database you can stop the server using:

```sh
Christian Pointner's avatar
Christian Pointner committed
120
$ ./contrib/mysql/stop_server.sh
Christian Pointner's avatar
Christian Pointner committed
121
122
123
124
125
```

### postgres

```sh
Christian Pointner's avatar
Christian Pointner committed
126
$ ./contrib/postgres/run_server.sh
Christian Pointner's avatar
Christian Pointner committed
127
128
129
130
131
```

Wait for the server to boot up and then initialize the database using a second terminal:

```sh
Christian Pointner's avatar
Christian Pointner committed
132
$ ./contrib/postgres/run_client.sh
Christian Pointner's avatar
Christian Pointner committed
133
$$$ psql < init.sql
Christian Pointner's avatar
Christian Pointner committed
134
135
136
```

This command can also be used to empty the database if you want to start with a new one.
Christian Pointner's avatar
Christian Pointner committed
137
138
139
After the daemon has ran the initial migrations you may check out the schema of the database:

```sh
Christian Pointner's avatar
Christian Pointner committed
140
$$$ psql < info.sql
Christian Pointner's avatar
Christian Pointner committed
141
```
Christian Pointner's avatar
Christian Pointner committed
142

143
Once you are done with the database you can stop the server by pressing `CTRL-C` inside the
Christian Pointner's avatar
Christian Pointner committed
144
terminal of the server.