https://github.com/kasefuchs/lazygate
Gate proxy plugin that shuts down your Minecraft server when it's idle and wakes it up when players connect.
https://github.com/kasefuchs/lazygate
docker gate-extension go golang minecraft minekube nomad plugin
Last synced: about 2 months ago
JSON representation
Gate proxy plugin that shuts down your Minecraft server when it's idle and wakes it up when players connect.
- Host: GitHub
- URL: https://github.com/kasefuchs/lazygate
- Owner: kasefuchs
- License: mit
- Created: 2024-10-24T10:58:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-07T08:48:43.000Z (over 1 year ago)
- Last Synced: 2024-11-17T05:30:07.179Z (over 1 year ago)
- Topics: docker, gate-extension, go, golang, minecraft, minekube, nomad, plugin
- Language: Go
- Homepage:
- Size: 136 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LazyGate
## Table of Contents
- [About](#about)
- [Getting Started](#getting_started)
**LazyGate** is a [Gate proxy](https://github.com/minekube/gate) plugin that automatically manages the uptime of your Minecraft server. It stops the server when idle and starts it again when players connect.
### Installing
Add the `lazygate` module to your project:
```sh
go get github.com/kasefuchs/lazygate
```
Include the plugin in your list of proxy plugins:
```go
package main
import (
lazygate "github.com/kasefuchs/lazygate/pkg/plugin"
"go.minekube.com/gate/cmd/gate"
"go.minekube.com/gate/pkg/edition/java/proxy"
)
func main() {
proxy.Plugins = append(proxy.Plugins, lazygate.NewProxyPlugin())
gate.Execute()
}
```
### Configuring
Configure the plugin using environment variables:
```sh
# Provider to use. Currently available nomad, docker and pufferpanel.
LAZYGATE_PLUGIN_PROVIDER="nomad"
# Namespace to use.
LAZYGATE_PLUGIN_NAMESPACE="default"
```
### Usage
#### Docker
LazyGate matches registered Gate servers with provider's allocations using labels:
**Docker Compose:**
```yaml
services:
minecraft-server-random:
labels:
lazygate.allocation.server: random_name
lazygate.allocation.time.minimumOnline: 2m
lazygate.allocation.time.inactivityThreshold: 5m
lazygate.queues: wait,kick
lazygate.queue.wait.timeout: 10s
lazygate.queue.wait.pingInterval: 2s
lazygate.queue.kick.reason: random_name is currently starting!
```
**Gate config:**
```yaml
---
config:
servers:
random_name: minecraft-server-random:25565
try:
- random_name
```
In this example, the `random_name` server will correspond to the `minecraft-server1` service.
#### PufferPanel
**Enviroment Variables for Gate**
```sh
LAZYGATE_PLUGIN_PROVIDER="pufferpanel"
LAZYGATE_PLUGIN_NAMESPACE="default"
LAZYGATE_PROVIDER_PUFFERPANEL_BASEURL=""
LAZYGATE_PROVIDER_PUFFERPANEL_CLIENTID=""
LAZYGATE_PROVIDER_PUFFERPANEL_CLIENTSECRET=""
LAZYGATE_PROVIDER_PUFFERPANEL_CONFIGFILEPATH="lazygate.json"
```
**_URL:_** The Url from pufferpanel e.g. `https://panel.example.com`
**_CLIENTID & CLIENTSECRET:_** The Client ID and Client Secret can you generate from Pufferpanel. Account (Top Right) -> OAuth2 Client -> Create New OAuth Client
**Gate config:**
```yaml
---
config:
servers:
random_name: minecraft-server-random:25565
try:
- random_name
```
**Server config**
Create a `lazygate.json` file inside pufferpanel files:
```json
{
"lazygate.allocation.server": "random_name",
"lazygate.allocation.time.minimumOnline": "2m",
"lazygate.allocation.time.inactivityThreshold": "5m",
"lazygate.queues": "wait,kick",
"lazygate.queue.wait.timeout": "10s",
"lazygate.queue.wait.pingInterval": "2s",
"lazygate.queue.kick.reason": "random_name is currently starting!"
}
```
**Extras**
If you're running your Gate Server also inside Docker on the same host as Pufferpanel you have to pass your pufferpanel domain as extrahost.