chore: minor files update.

This commit is contained in:
Houmgaor
2025-10-18 18:57:16 +02:00
parent 1268a77712
commit f410cbd48b
4 changed files with 60 additions and 34 deletions

5
.gitignore vendored
View File

@@ -8,4 +8,7 @@ savedata/*/
*.lnk *.lnk
*.bat *.bat
/docker/db-data /docker/db-data
screenshots/* screenshots/*
# We don't need the built file
erupe-ce

View File

@@ -1,4 +1,4 @@
FROM golang:1.21-alpine3.19 FROM golang:1.25-alpine3.21
ENV GO111MODULE=on ENV GO111MODULE=on

View File

@@ -1,18 +1,25 @@
# Docker for erupe # Docker for erupe
## Building the container ## Building the container
Run the following from the route of the soruce folder. In this example we give it the tag of dev to seperate it from any other container verions.
Run the following from the route of the source folder. In this example we give it the tag of dev to seperate it from any other container verions.
```bash ```bash
docker build . -t erupe:dev docker build . -t erupe:dev
``` ```
## Running the container in isolation ## Running the container in isolation
This is just running the container. You can do volume mounts into the container for the `config.json` to tell it to communicate to a database. You will need to do this also for other folders such as `bin` and `savedata` This is just running the container. You can do volume mounts into the container for the `config.json` to tell it to communicate to a database. You will need to do this also for other folders such as `bin` and `savedata`
```bash ```bash
docker run erupe:dev docker run erupe:dev
``` ```
## Docker compose ## Docker compose
Docker compose allows you to run multiple containers at once. The docker compose in this folder has 3 things set up. Docker compose allows you to run multiple containers at once. The docker compose in this folder has 3 things set up.
- postgres - postgres
- pg admin (Admin interface to make db changes) - pg admin (Admin interface to make db changes)
- erupe - erupe
@@ -21,7 +28,8 @@ We automatically populate the database to the latest version on start. If you yo
Before we get started you should make sure the database info matches whats in the docker compose file for the environment variables `POSTGRES_PASSWORD`,`POSTGRES_USER` and `POSTGRES_DB`. You can set the host to be the service name `db`. Before we get started you should make sure the database info matches whats in the docker compose file for the environment variables `POSTGRES_PASSWORD`,`POSTGRES_USER` and `POSTGRES_DB`. You can set the host to be the service name `db`.
Here is a example of what you would put in the config.json if you was to leave the defaults. It is strongly recommended to change the password. Here is a example of what you would put in the config.json if you was to leave the defaults. It is strongly recommended to change the password.
```txt ```txt
"Database": { "Database": {
"Host": "db", "Host": "db",
@@ -36,35 +44,43 @@ Place this file within ./docker/config.json
You will need to do the same for your bins place these in ./docker/bin You will need to do the same for your bins place these in ./docker/bin
# Setting up the web hosted materials ## Setting up the web hosted materials
Clone the Severs repo into ./docker/Severs Clone the Severs repo into ./docker/Severs
Make sure your hosts are pointing to where this is hosted Make sure your hosts are pointing to where this is hosted
## Turning off the server safely ## Turning off the server safely
```bash ```bash
docker-compose stop docker-compose stop
``` ```
## Turning off the server destructive ## Turning off the server destructive
```bash ```bash
docker-compose down docker-compose down
``` ```
Make sure if you want to delete your data you delete the folders that persisted Make sure if you want to delete your data you delete the folders that persisted
- ./docker/savedata - ./docker/savedata
- ./docker/db-data - ./docker/db-data
## Turning on the server again
## Turning on the server again
This boots the db pgadmin and the server in a detached state This boots the db pgadmin and the server in a detached state
```bash ```bash
docker-compose up -d docker-compose up -d
``` ```
if you want all the logs and you want it to be in an attached state
if you want all the logs and you want it to be in an attached state
```bash ```bash
docker-compose up docker-compose up
``` ```
## Troubleshooting
# Troubleshooting Q: My Postgres will not populate. A: You're setup.sh is maybe saved as CRLF it needs to be saved as LF.
Q: My Postgres will not populate. A: You're setup.sh is maybe saved as CRLF it needs to be saved as LF.

53
main.go
View File

@@ -40,6 +40,31 @@ var Commit = func() string {
return "unknown" return "unknown"
} }
func setupDiscordBot(db *discordbot.DiscordBot, logger *zap.Logger) {
bot, err := discordbot.NewDiscordBot(discordbot.Options{
Logger: logger,
Config: _config.ErupeConfig,
})
if err != nil {
preventClose(fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
}
// Discord bot
err = bot.Start()
if err != nil {
preventClose(fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
}
*db = *bot
_, err = bot.Session.ApplicationCommandBulkOverwrite(bot.Session.State.User.ID, "", discordbot.Commands)
if err != nil {
preventClose(fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
}
}
func main() { func main() {
var err error var err error
@@ -74,28 +99,7 @@ func main() {
var discordBot *discordbot.DiscordBot = nil var discordBot *discordbot.DiscordBot = nil
if config.Discord.Enabled { if config.Discord.Enabled {
bot, err := discordbot.NewDiscordBot(discordbot.Options{ setupDiscordBot(discordBot, logger)
Logger: logger,
Config: _config.ErupeConfig,
})
if err != nil {
preventClose(fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
}
// Discord bot
err = bot.Start()
if err != nil {
preventClose(fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
}
discordBot = bot
_, err = discordBot.Session.ApplicationCommandBulkOverwrite(discordBot.Session.State.User.ID, "", discordbot.Commands)
if err != nil {
preventClose(fmt.Sprintf("Discord: Failed to start, %s", err.Error()))
}
logger.Info("Discord: Started successfully") logger.Info("Discord: Started successfully")
} else { } else {
@@ -226,7 +230,10 @@ func main() {
if err != nil { if err != nil {
preventClose(fmt.Sprintf("Channel: Failed to start, %s", err.Error())) preventClose(fmt.Sprintf("Channel: Failed to start, %s", err.Error()))
} else { } else {
channelQuery += fmt.Sprintf(`INSERT INTO servers (server_id, current_players, world_name, world_description, land) VALUES (%d, 0, '%s', '%s', %d);`, sid, ee.Name, ee.Description, i+1) channelQuery += fmt.Sprintf(
`INSERT INTO servers (server_id, current_players, world_name, world_description, land) VALUES (%d, 0, '%s', '%s', %d);`,
sid, ee.Name, ee.Description, i+1
)
channels = append(channels, &c) channels = append(channels, &c)
logger.Info(fmt.Sprintf("Channel %d (%d): Started successfully", count, ce.Port)) logger.Info(fmt.Sprintf("Channel %d (%d): Started successfully", count, ce.Port))
ci++ ci++