azukaar / Cosmos-Server

☁️ The Most Secure and Easy Selfhosted Home Server. Take control of your data and privacy without sacrificing security and stability (Authentication, anti-DDOS, anti-bot)
https://cosmos-cloud.io
Other
3.45k stars 119 forks source link

[FEAT]: MongoDB custom port setting #315

Closed gaabora closed 3 weeks ago

gaabora commented 3 weeks ago

Feature Description

Hello. Currently port 27017 is hardcoded as mongodb custom static port https://github.com/search?q=repo%3Aazukaar%2FCosmos-Server%2027017&type=code Could you please make it a variable, cause it giving problems when having other servers, for example steam dedicated server can run on same port internally and then mongo is unable to bind that port and keep restarting... image

{ "LoggingLevel": "DEBUG", "MongoDB": "", "Database": { "DbVolume": "cosmos-mongo-data-123", "Version": "6", "DbPort": "12345", < maybe add this kind of setting please? ...

azukaar commented 3 weeks ago

There isn't really a point since the port is not exposed? Why do you want this?

gaabora commented 3 weeks ago

There isn't really a point since the port is not exposed? Why do you want this? Do you know how to solve the issue then? Before cosmos was installed there was already running docker compose with

services: l4d: image: rpufky/steam:stable restart: unless-stopped container_name: l4d2b stop_grace_period: 5s ports:

networks: default: external: name: ${NETWORK}

then suddenly one day both cosmos and all servers that are behind it's proxy stopped responding. I restarted the machine and then saw in logs like on image above that mongo from cosmos-server is restaring all the time.

l guess key problem is another container that is in external network using port 27017? Cause stopping that container did let mongo start.

azukaar commented 3 weeks ago

Did you expose the port in Cosmos' Mongo? It's not supposed to be exported if it's not exposed then the issue is probably not a port issue because you can have as many MOngoDB as you want on your machine

gaabora commented 3 weeks ago

no, I do not use mongo anywhere, exposed only 27017 port that used for steam server that is in external network

azukaar commented 3 weeks ago

Then the issue you are experiencing is definitely not related to port issues because the Cosmos one is not external maybe bring up the log of your DB when its crashing? could be a RAM issue for example

gaabora commented 3 weeks ago

Checked bloated logs of mongo container, haven't found any useful info haven't touch it after, then today noticed server not responding again, logged to ssh and found out that mongodb container magically disappeared

is there a way to recover or how to deal with it? docker volume list DRIVER VOLUME NAME local cosmos-mongo-config-8SX local cosmos-mongo-data-8SX

2024/09/11 07:17:27 [INFO] Starting Cosmos-Server version 0.15.7 2024/09/11 07:17:27 [INFO] ------------------------------------------ 2024/09/11 07:17:27 [INFO] Using config file: /config/cosmos.config.json 2024/09/11 07:17:27 [INFO] Validating config file... 2024/09/11 07:17:57 [ERROR] Puppet mode enabled. DB not found. Recreating DB... : server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: 172.17.0.2:27017, Type: Unknown, Last error: dial tcp 172.17.0.2:27017: connect: no route to host }, ] } 2024/09/11 07:17:57 [WARN] CPU does not support AVX. Using mongo 4.4 2024/09/11 07:17:59 [WARN] CreateService: Container cosmos-mongo-8SX already exist, overwriting. 2024/09/11 07:18:02 [ERROR] Metrics - Error fetching Temperature: : Number of warnings: 1 2024/09/11 07:18:32 [ERROR] Metrics - Error fetching Temperature: : Number of warnings: 1 2024/09/11 07:18:33 [ERROR] Metrics: Error fetching metrics : server selection error: server selection timeout, current topology: { Type: Unknown, Servers: [{ Addr: 172.17.0.2:27017, Type: Unknown, Last error: dial tcp 172.17.0.2:27017: connect: no route to host }, ] } panic: runtime error: invalid memory address or nil pointer dereference panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x23bba6e]

goroutine 90 [running]: go.mongodb.org/mongo-driver/mongo.(Cursor).closeImplicitSession(0x0?) /home/circleci/.go_workspace/pkg/mod/go.mongodb.org/mongo-driver@v1.14.0/mongo/cursor.go:380 +0xe panic({0x2bc0e60?, 0x58c2190?}) /usr/local/go/src/runtime/panic.go:914 +0x21f go.mongodb.org/mongo-driver/mongo.(Cursor).Close(0x0?, {0x0?, 0x0?}) /home/circleci/.go_workspace/pkg/mod/go.mongodb.org/mongo-driver@v1.14.0/mongo/cursor.go:285 +0x54 github.com/azukaar/cosmos-server/src/metrics.AggloMetrics({0xc000c531f0, 0x0, 0x20?}) /home/circleci/project/src/metrics/aggl.go:81 +0x43b github.com/azukaar/cosmos-server/src/metrics.AggloAndCommitMetrics() /home/circleci/project/src/metrics/aggl.go:254 +0x50 reflect.Value.call({0x2973400?, 0x3517008?, 0x13691940?}, {0x33e86ed, 0x4}, {0x597f3e0, 0x0, 0x0?}) /usr/local/go/src/reflect/value.go:596 +0xce7 reflect.Value.Call({0x2973400?, 0x3517008?, 0x0?}, {0x597f3e0?, 0x0?, 0x0?}) /usr/local/go/src/reflect/value.go:380 +0xb9 github.com/jasonlvhit/gocron.callJobFuncWithParams({0x2973400?, 0x3517008?}, {0x0, 0x0, 0x0?}) /home/circleci/.go_workspace/pkg/mod/github.com/jasonlvhit/gocron@v0.0.1/gocron.go:78 +0x1d6 github.com/jasonlvhit/gocron.(Job).run(0x3517030?) /home/circleci/.go_workspace/pkg/mod/github.com/jasonlvhit/gocron@v0.0.1/job.go:66 +0x24b created by github.com/jasonlvhit/gocron.(Scheduler).RunPending in goroutine 70 /home/circleci/.go_workspace/pkg/mod/github.com/jasonlvhit/gocron@v0.0.1/scheduler.go:90 +0x127

azukaar commented 3 weeks ago

Seems like you are using some weak hardware, maybe you are hitting some hardware limitation (storage or RAM for example?) preventing the DB from running properly?

gaabora commented 3 weeks ago

thank you for your responses, idk wtf is happening, after 20 minutes it appeared out of nowhere again and working 🤯 could that be due to space? looks like there was 2 gigs of free space only... but 2 gigs, cmon... is there a way to make mongodb stop write most of that useless diagnostics bs, or should I move mongodb to separate container to tune it's settings?

image

azukaar commented 3 weeks ago

" 2 gigs of free space only... but 2 gigs, cmon... " could be an issue if your RAM is swapping to the disk maybe? I dont know just a hypothesis