nicho92 / MtgDesktopCompanion

Cards manager for magic the gathering
Apache License 2.0
154 stars 33 forks source link

Docker Container crashes because of Jetty minThreads #274

Closed janpfischer closed 3 months ago

janpfischer commented 3 months ago

Describe the bug Hi, I am trying to run the WebUI Docker container in my kubernetes cluster. The application starts and I can access the webui. But I can't access the JSON server.

At the end of the start up the app logs this error:

2024-03-29 11:17:05 [ERROR] org.magic.servers.impl.JSONHttpServer 303 - java.lang.IllegalArgumentException: max threads (4) less than min threads (8)
Exception in thread "Thread-13" java.lang.NullPointerException: Cannot invoke "org.eclipse.jetty.server.Server.join()" because "this.server" is null
    at spark.embeddedserver.jetty.EmbeddedJettyServer.join(EmbeddedJettyServer.java:163)
    at spark.Service.lambda$init$2(Service.java:645)
    at java.base/java.lang.Thread.run(Thread.java:1583)

I believe that this error leads to the unavailability of the JSON server. My server is not the strongest and has not more than 4 threads. I believe the minThreads Jetty setting of 8 is the default. Is there a way to configure this to 4?

Thank you very much!

nicho92 commented 3 months ago

Hi !!

You can change THREAD value in the container file store: put 8 instead of 4. The file is : /server/Json Http Server.conf

image

janpfischer commented 3 months ago

Strange, this is already set to "4". I did not change that.

debug-mtgcompanion-data:/data/config/server# cat Json\ Http\ Server.conf
#
#Fri Mar 29 11:09:28 UTC 2024
AUTOSTART=false
Access-Control-Allow-Headers=Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin
Access-Control-Allow-Origin=*
Access-Control-Request-Method=GET,PUT,POST,DELETE,OPTIONS
BLOCKED_IPS=
ENABLE_GZIP=true
ENABLE_SSL=false
INDEX_ROUTES=true
JWT_EXPIRATION_MINUTES=60
JWT_REFRESH_EXPIRATION_MINUTES=21600
JWT_SECRET=changed
KEYSTORE_PASS=changeit
KEYSTORE_URI=/.magicDeskCompanion/data/jetty.jks
PRETTY_PRINT=false
SERVER-PORT=8080
THREADS=4
TIMEOUT_CACHE_MINUTES=720

Update: The overall server crash loop is fixed, that was a configuration error on my side. I've updated the initial Issue report.

nicho92 commented 3 months ago

The default value is setup by MTGCompanion with the Runtime.availableProcessors() function of java.

Update: The overall server crash loop is fixed, that was a configuration error on my side. I've updated the initial Issue report. Is it OK now or the crash persist ?

janpfischer commented 3 months ago

The application crash is fixed, but the problem with starting the JSON Server is still there. It still tries with 8 threads.

Maybe the default value is correctly set with Runtime.availableProcessors() but the Jetty server does not read this setting at startup? Would explain why the file reads 4 but the startup log says that "min threads" is 8.

nicho92 commented 3 months ago

Strange, this is already set to "4". I did not change that

The THREAD parameter is for MAX thread value ;)

Then you should set 8 to the value and not 4

janpfischer commented 3 months ago

Okay, understood. Changed it and the server started. Thanks! But wouldn't it make sense if the minThreads Parameter would be adjusted if maxThreads < minThreads? Espacially if the initial value is set with Runtime.availableProcessors(). Because as of now I had to set the maxThreads to more Threads that I have on the machine. I believe minThreads 8 is the Jetty default. So would be good if it is automatically adjusted and/or can be set in the configuration.

nicho92 commented 3 months ago

Yup, i'm working on it ;)

janpfischer commented 3 months ago

Awesome, thank you!