Skip to content

Commit eb9d7b7

Browse files
authored
add support for spring cloud config & docs (#1144)
1 parent 43e44a4 commit eb9d7b7

File tree

15 files changed

+392
-137
lines changed

15 files changed

+392
-137
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
spring:
2+
cloud:
3+
config:
4+
enabled: true
5+
# Set the application name here
6+
name: Lavalink
7+
# Set profile here (default: default)
8+
profile: node1
9+
# Set the label (git branch/commit id/release) (default: main/master)
10+
label: main
11+
# Fail if no config could be found
12+
fail-fast: true
13+
config:
14+
# replace http://localhost:8888 with the url to your Lavalink Config Server
15+
import: "configserver:http://localhost:8888/"

LavalinkServer/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ dependencies {
5656
implementation(libs.xmlutil.serialization)
5757

5858
implementation(libs.bundles.metrics)
59+
implementation(libs.spring.cloud.config)
5960
implementation(libs.bundles.spring) {
6061
exclude(group = "org.springframework.boot", module = "spring-boot-starter-tomcat")
6162
}

LavalinkServer/src/main/resources/application.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ spring:
33
version: "1.0"
44
formatted-version: "(v1.0)"
55
name: "Lavalink"
6+
cloud:
7+
config:
8+
enabled: false
69
server:
710
error:
811
include-message: ALWAYS
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
spring:
2+
cloud:
3+
config:
4+
enabled: false
5+
16
lavalink:
27
server:
38
password: "youshallnotpass"
49

5-
componentScan: []
10+
componentScan: [ ]

docs/configuration/binary.md

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
description: How to configure Lavalink with the Config File
3+
---
4+
5+
# Config File
6+
7+
The server configuration is done in `application.yml`. You can find an example below.
8+
9+
## Example application.yml
10+
11+
```yaml title="application.yml"
12+
--8<-- "LavalinkServer/application.yml.example"
13+
```
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
description: How to configure Lavalink with the Config Server
3+
---
4+
5+
# Config Server
6+
7+
## Example Lavalink application.yml
8+
9+
To configure Lavalink to pull it's configuration from a [Lavalink Config Server](https://github.com/lavalink-devs/Lavalink-Config-Server) you need to put the following in your `application.yml` file:
10+
11+
```yaml title="application.yml"
12+
--8<-- "LavalinkServer/application.yml.cloud-example"
13+
```
14+
15+
Alternatively, this can also be done via environment variables:
16+
17+
<details markdown="1">
18+
<summary>Environment Variables</summary>
19+
20+
```bash
21+
SPRING_APPLICATION_NAME
22+
SPRING_CLOUD_CONFIG_PROFILE
23+
SPRING_CLOUD_CONFIG_LABEL
24+
SPRING_CLOUD_CONFIG_FAIL_FAST
25+
26+
SPRING_CONFIG_IMPORT
27+
```
28+
29+
</details>
30+
31+
## Running the Lavalink Config Server
32+
33+
To run the Lavalink Config Server, you can use the docker image located at [`ghcr.io/lavalink-devs/lavalink-config-server`](https://github.com/lavalink-devs/Lavalink-Config-Server/pkgs/container/lavalink-config-server)
34+
35+
### Example docker-compose.yml
36+
37+
```yaml
38+
services:
39+
lavalink-config-server:
40+
image: ghcr.io/lavalink-devs/lavalink-config-server:master
41+
container_name: lavalink-config-server
42+
restart: unless-stopped
43+
environment:
44+
# set the environment variables for the config server here
45+
volumes:
46+
# mount application.yml from the same directory, if you want to use environment variables remove this line below
47+
- ./application.yml:/opt/Lavalink-Config-Server/application.yml
48+
networks:
49+
- lavalink
50+
expose:
51+
# lavalink Config Server exposes port 8888 to pull config from
52+
- 8888
53+
ports:
54+
# you only need this if you want to make your Lavalink Config Server accessible from outside of containers, keep in mind this will expose your lavalink Config Server to the internet
55+
- "8888:8888"
56+
# if you want to restrict access to localhost only
57+
# - "127.0.0.1:8888:8888"
58+
networks:
59+
# create a lavalink network you can add other containers to, to give them access to Lavalink
60+
lavalink:
61+
name: lavalink
62+
```
63+
64+
### Example application.yml
65+
66+
The Lavalink Config Server can be configured to use a git repository or a local filesystem as the backend for the configuration files.
67+
68+
```yaml title="application.yml"
69+
spring:
70+
profiles:
71+
# Set to native to use a local filesystem/static url
72+
active: git
73+
cloud:
74+
config:
75+
server:
76+
# Set to true to allow empty config files to be accepted
77+
accept-empty: false
78+
# See: https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_git_backend
79+
git:
80+
# The uri supports the following placeholders: {application}, {profile} & {label}
81+
uri: "https://github.com/lavalink-devs/Lavalink-Example-Configs"
82+
# set this to {application} if you group your configs by application
83+
search-paths: "{application}"
84+
skipSslValidation: false
85+
timeout: 5
86+
cloneOnStart: true
87+
force-pull: false
88+
deleteUntrackedBranches: false
89+
refreshRate: 0
90+
# username: trolley
91+
# for GitHub, use a personal access token
92+
# password: strongpassword
93+
defaultLabel: main
94+
# See: https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_file_system_backend
95+
native:
96+
# when using the native backend, the searchLocations supports the following placeholders: {application}, {profile} & {label}
97+
# make sure to tell the lavalink config server a specific config location via spring.config.location=application.yml
98+
# or else it will try to load its own config from any subdirectory your lavalink server configs might be in
99+
searchLocations: "file:config/{application}"
100+
101+
server:
102+
port: 8888
103+
address: 127.0.0.1
104+
105+
logging:
106+
level:
107+
root: INFO
108+
org.springframework.cloud.config: DEBUG
109+
```
110+
111+
Alternatively, this can also be done via environment variables:
112+
113+
<details markdown="1">
114+
<summary>Environment Variables</summary>
115+
116+
```bash
117+
SPRING_PROFILES_ACTIVE
118+
119+
SPRING_CLOUD_CONFIG_SERVER_ACCEPT_EMPTY
120+
121+
SPRING_CLOUD_CONFIG_SERVER_GIT_URI
122+
SPRING_CLOUD_CONFIG_SERVER_GIT_SEARCH_PATHS
123+
SPRING_CLOUD_CONFIG_SERVER_GIT_SKIP_SSL_VALIDATION
124+
SPRING_CLOUD_CONFIG_SERVER_GIT_TIMEOUT
125+
SPRING_CLOUD_CONFIG_SERVER_GIT_CLONE_ON_START
126+
SPRING_CLOUD_CONFIG_SERVER_GIT_FORCE_PULL
127+
SPRING_CLOUD_CONFIG_SERVER_GIT_DELETE_UNTRACKED_BRANCHES
128+
SPRING_CLOUD_CONFIG_SERVER_GIT_REFRESH_RATE
129+
SPRING_CLOUD_CONFIG_SERVER_GIT_USERNAME
130+
SPRING_CLOUD_CONFIG_SERVER_GIT_PASSWORD
131+
SPRING_CLOUD_CONFIG_SERVER_GIT_DEFAULT_LABEL
132+
133+
SPRING_CLOUD_CONFIG_SERVER_NATIVE_SEARCH_LOCATIONS
134+
135+
SERVER_PORT
136+
SERVER_ADDRESS
137+
138+
LOGGING_LEVEL_ROOT
139+
LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_CONFIG
140+
```
141+
142+
</details>
143+
144+
### Example config repository
145+
146+
See [Lavalink Example Configs](https://github.com/lavalink-devs/Lavalink-Example-Configs) for an example config repository.
147+
148+
#### Structure
149+
150+
The config repository should have the following structure:
151+
152+
```text
153+
.
154+
├── lavalink
155+
│ ├── application.yml
156+
│ └── application-{profile}.yml
157+
```
158+
159+
The `application.yml` file is the default configuration file.
160+
The `application-{profile}.yml` file is the configuration file for the specified profile and overrides the config entries in the default configuration file.
161+
The profile name can be set in the [`application.yml`](#example-applicationyml) file of the Lavalink server.
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
description: How to configure Lavalink
3+
---
4+
5+
# Configuration
6+
7+
The server configuration is done in `application.yml`. You can find an example below.
8+
9+
## Example application.yml
10+
11+
<details markdown="1">
12+
<summary>application.yml</summary>
13+
14+
```yaml title="application.yml"
15+
--8<-- "LavalinkServer/application.yml.example"
16+
```
17+
18+
</details>
19+
20+
Alternatively, you can also use environment variables to configure the server. The environment variables are named the same as the keys in the `application.yml` file, but in uppercase and with `.` replaced with `_`. For example, `server.port` becomes `SERVER_PORT`.
21+
For arrays, the index is appended to the key, starting at 0. For example, `LAVALINK_PLUGINS_0_DEPENDENCY` refers to the `dependency` key of the first plugin.
22+
23+
## Example environment variables
24+
25+
<details markdown="1">
26+
<summary>environment variables</summary>
27+
28+
```env title="enviroment variables"
29+
SERVER_PORT
30+
SERVER_ADDRESS
31+
SERVER_HTTP2_ENABLED
32+
33+
LAVALINK_PLUGINS_0_DEPENDENCY
34+
LAVALINK_PLUGINS_0_REPOSITORY
35+
36+
LAVALINK_PLUGINS_1_DEPENDENCY
37+
LAVALINK_PLUGINS_1_REPOSITORY
38+
39+
LAVALINK_PLUGINS_DIR
40+
LAVALINK_DEFAULT_PLUGIN_REPOSITORY
41+
LAVALINK_DEFAULT_PLUGIN_SNAPSHOT_REPOSITORY
42+
43+
LAVALINK_SERVER_PASSWORD
44+
LAVALINK_SERVER_SOURCES_YOUTUBE
45+
LAVALINK_SERVER_SOURCES_BANDCAMP
46+
LAVALINK_SERVER_SOURCES_SOUNDCLOUD
47+
LAVALINK_SERVER_SOURCES_TWITCH
48+
LAVALINK_SERVER_SOURCES_VIMEO
49+
LAVALINK_SERVER_SOURCES_HTTP
50+
LAVALINK_SERVER_SOURCES_NICO
51+
LAVALINK_SERVER_SOURCES_LOCAL
52+
53+
LAVALINK_SERVER_FILTERS_VOLUME
54+
LAVALINK_SERVER_FILTERS_EQUALIZER
55+
LAVALINK_SERVER_FILTERS_KARAOKE
56+
LAVALINK_SERVER_FILTERS_TIMESCALE
57+
LAVALINK_SERVER_FILTERS_TREMOLO
58+
LAVALINK_SERVER_FILTERS_VIBRATO
59+
LAVALINK_SERVER_FILTERS_DISTORTION
60+
LAVALINK_SERVER_FILTERS_ROTATION
61+
LAVALINK_SERVER_FILTERS_CHANNEL_MIX
62+
LAVALINK_SERVER_FILTERS_LOW_PASS
63+
64+
LAVALINK_SERVER_BUFFER_DURATION_MS
65+
LAVALINK_SERVER_FRAME_BUFFER_DURATION_MS
66+
LAVALINK_SERVER_OPUS_ENCODING_QUALITY
67+
LAVALINK_SERVER_RESAMPLING_QUALITY
68+
LAVALINK_SERVER_TRACK_STUCK_THRESHOLD_MS
69+
LAVALINK_SERVER_USE_SEEK_GHOSTING
70+
71+
LAVALINK_SERVER_PLAYER_UPDATE_INTERVAL
72+
LAVALINK_SERVER_YOUTUBE_SEARCH_ENABLED
73+
LAVALINK_SERVER_SOUNDCLOUD_SEARCH_ENABLED
74+
75+
LAVALINK_SERVER_GC_WARNINGS
76+
77+
LAVALINK_SERVER_RATELIMIT_IP_BLOCKS
78+
LAVALINK_SERVER_RATELIMIT_EXCLUDE_IPS
79+
LAVALINK_SERVER_RATELIMIT_STRATEGY
80+
LAVALINK_SERVER_RATELIMIT_SEARCH_TRIGGERS_FAIK
81+
LAVALINK_SERVER_RATELIMIT_RETRY_LIMIT
82+
83+
LAVALINK_SERVER_YOUTUBE_CONFIG_EMAIL
84+
LAVALINK_SERVER_YOUTUBE_CONFIG_PASSWORD
85+
86+
LAVALINK_SERVER_HTTP_CONFIG_PROXY_HOST
87+
LAVALINK_SERVER_HTTP_CONFIG_PROXY_PORT
88+
LAVALINK_SERVER_HTTP_CONFIG_PROXY_USER
89+
LAVALINK_SERVER_HTTP_CONFIG_PROXY_PASSWORD
90+
91+
METRICS_PROMETHEUS_ENABLED
92+
METRICS_PROMETHEUS_ENDPOINT
93+
94+
SENTRY_DSN
95+
SENTRY_ENVIRONMENT
96+
SENTRY_TAGS_SOME_KEY
97+
SENTRY_TAGS_ANOTHER_KEY
98+
99+
LOGGING_FILE_PATH
100+
LOGGING_LEVEL_ROOT
101+
LOGGING_LEVEL_LAVALINK
102+
103+
LOGGING_REQUEST_ENABLED
104+
LOGGING_REQUEST_INCLUDE_CLIENT_INFO
105+
LOGGING_REQUEST_INCLUDE_HEADERS
106+
LOGGING_REQUEST_INCLUDE_QUERY_STRING
107+
LOGGING_REQUEST_INCLUDE_PAYLOAD
108+
LOGGING_REQUEST_MAX_PAYLOAD_LENGTH
109+
110+
LOGGING_LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE
111+
LOGGING_LOGBACK_ROLLINGPOLICY_MAX_HISTORY
112+
```
113+
114+
</details>
115+
116+
You can also use a combination of both. Environment variables take precedence over the `application.yml` file.

0 commit comments

Comments
 (0)