Skip to content

Commit

Permalink
Merge pull request #53 from MongoCamp/startup-fix
Browse files Browse the repository at this point in the history
Startup fix
  • Loading branch information
QuadStingray authored Oct 21, 2023
2 parents c60cba7 + 31256d9 commit a522701
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 119 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ RUN eval "$(cs java --jvm $GRAAL_VERSION --env)"; $JAVA_HOME/bin/gu install nati
#RUN /mongocamp-cli/mongocamp-cli/target/graalvm-native-image/mongocamp-cli prepare cache;

FROM debian:12.1-slim
ENV PLUGINS_DIRECTORY="/opt/mongocamp/plugins"
COPY --from=builder /mongocamp-cli/mongocamp-cli/target/graalvm-native-image/mongocamp-cli /opt/bin/mongocamp-cli
## todo: reactivate build if fixed. https://github.com/oracle/graal/issues/7264
## COPY --from=builder /mongocamp-cli/server-raw /opt/bin/server-raw
ENV MODE="default"
WORKDIR /opt/bin/
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections; apt-get update; apt-get install -y snappy-dev zlib-dev bash; apt-get -y upgrade;
## todo: reactivate build if fixed. https://github.com/oracle/graal/issues/7264
# RUN mkdir -p /opt/mongocamp/plugins; chmod -R 777 /opt/mongocamp/plugins; chmod +x /opt/bin/mongocamp-cli; chmod +x /opt/bin/server-raw; apt-get update;
RUN mkdir -p /opt/mongocamp/plugins; chmod -R 777 /opt/mongocamp/plugins; chmod +x /opt/bin/mongocamp-cli;
RUN mkdir -p $PLUGINS_DIRECTORY; chmod -R 777 $PLUGINS_DIRECTORY; chmod +x /opt/bin/mongocamp-cli;
RUN ./mongocamp-cli prepare cache;
ENTRYPOINT ./mongocamp-cli run $MODE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Args = -H:ReflectionConfigurationResources=${.}/reflection-config.json \
-H:ResourceConfigurationResources=${.}/resource-config.json \
--initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback \
--initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback,dev.mongocamp.driver.mongodb.Converter,dev.mongocamp.driver.mongodb.bson.BsonConverter,dev.mongocamp.driver.mongodb.Converter$,dev.mongocamp.driver.mongodb.bson.BsonConverter$ \
--enable-url-protocols=https,http
Original file line number Diff line number Diff line change
Expand Up @@ -121,111 +121,159 @@
"allPublicClasses": true
},
{
"name":"com.github.benmanes.caffeine.cache.AccessOrderDeque$AccessOrder"
"name": "com.github.benmanes.caffeine.cache.AccessOrderDeque$AccessOrder"
},
{
"name":"com.github.benmanes.caffeine.cache.AsyncCache"
"name": "com.github.benmanes.caffeine.cache.AsyncCache"
},
{
"name":"com.github.benmanes.caffeine.cache.AsyncCacheLoader"
"name": "com.github.benmanes.caffeine.cache.AsyncCacheLoader"
},
{
"name":"com.github.benmanes.caffeine.cache.BBHeader$PadReadCounter"
"name": "com.github.benmanes.caffeine.cache.BBHeader$PadReadCounter"
},
{
"name":"com.github.benmanes.caffeine.cache.BLCHeader$DrainStatusRef",
"fields":[{"name":"drainStatus"}]
"name": "com.github.benmanes.caffeine.cache.BLCHeader$DrainStatusRef",
"fields": [
{
"name": "drainStatus"
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.BLCHeader$PadDrainStatus"
"name": "com.github.benmanes.caffeine.cache.BLCHeader$PadDrainStatus"
},
{
"name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueColdProducerFields",
"fields":[{"name":"producerLimit"}]
"name": "com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueColdProducerFields",
"fields": [
{
"name": "producerLimit"
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueConsumerFields",
"fields":[{"name":"consumerIndex"}]
"name": "com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueConsumerFields",
"fields": [
{
"name": "consumerIndex"
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueProducerFields",
"fields":[{"name":"producerIndex"}]
"name": "com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueProducerFields",
"fields": [
{
"name": "producerIndex"
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.BoundedLocalCache",
"fields":[{"name":"refreshes"}]
"name": "com.github.benmanes.caffeine.cache.BoundedLocalCache",
"fields": [
{
"name": "refreshes"
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.Buffer"
"name": "com.github.benmanes.caffeine.cache.Buffer"
},
{
"name":"com.github.benmanes.caffeine.cache.Cache"
"name": "com.github.benmanes.caffeine.cache.Cache"
},
{
"name":"com.github.benmanes.caffeine.cache.Expiry"
"name": "com.github.benmanes.caffeine.cache.Expiry"
},
{
"name":"com.github.benmanes.caffeine.cache.Interner"
"name": "com.github.benmanes.caffeine.cache.Interner"
},
{
"name":"com.github.benmanes.caffeine.cache.NodeFactory"
"name": "com.github.benmanes.caffeine.cache.NodeFactory"
},
{
"name":"com.github.benmanes.caffeine.cache.PS",
"fields":[
{"name":"key"},
{"name":"value"}
"name": "com.github.benmanes.caffeine.cache.PS",
"fields": [
{
"name": "key"
},
{
"name": "value"
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.PSW",
"fields":[{"name":"writeTime"}],
"methods":[{"name":"<init>","parameterTypes":[] }]
"name": "com.github.benmanes.caffeine.cache.PSW",
"fields": [
{
"name": "writeTime"
}
],
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.Policy"
"name": "com.github.benmanes.caffeine.cache.Policy"
},
{
"name":"com.github.benmanes.caffeine.cache.Policy$Eviction"
"name": "com.github.benmanes.caffeine.cache.Policy$Eviction"
},
{
"name":"com.github.benmanes.caffeine.cache.Policy$FixedExpiration"
"name": "com.github.benmanes.caffeine.cache.Policy$FixedExpiration"
},
{
"name":"com.github.benmanes.caffeine.cache.Policy$FixedRefresh"
"name": "com.github.benmanes.caffeine.cache.Policy$FixedRefresh"
},
{
"name":"com.github.benmanes.caffeine.cache.Policy$VarExpiration"
"name": "com.github.benmanes.caffeine.cache.Policy$VarExpiration"
},
{
"name":"com.github.benmanes.caffeine.cache.References$InternalReference"
"name": "com.github.benmanes.caffeine.cache.References$InternalReference"
},
{
"name": "com.github.benmanes.caffeine.cache.RemovalListener"
},
{
"name": "com.github.benmanes.caffeine.cache.SSSW",
"methods": [
{
"name": "<init>",
"parameterTypes": [
"com.github.benmanes.caffeine.cache.Caffeine",
"com.github.benmanes.caffeine.cache.AsyncCacheLoader",
"boolean"
]
}
]
},
{
"name":"com.github.benmanes.caffeine.cache.RemovalListener"
"name": "com.github.benmanes.caffeine.cache.Scheduler"
},
{
"name":"com.github.benmanes.caffeine.cache.SSSW",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.AsyncCacheLoader","boolean"] }]
"name": "com.github.benmanes.caffeine.cache.Ticker"
},
{
"name":"com.github.benmanes.caffeine.cache.Scheduler"
"name": "com.github.benmanes.caffeine.cache.Weigher"
},
{
"name":"com.github.benmanes.caffeine.cache.Ticker"
"name": "com.github.benmanes.caffeine.cache.WriteOrderDeque$WriteOrder"
},
{
"name":"com.github.benmanes.caffeine.cache.Weigher"
"name": "com.github.benmanes.caffeine.cache.stats.StatsCounter"
},
{
"name":"com.github.benmanes.caffeine.cache.WriteOrderDeque$WriteOrder"
"name": "com.github.blemale.scaffeine.AsyncCache"
},
{
"name":"com.github.benmanes.caffeine.cache.stats.StatsCounter"
"name": "com.github.blemale.scaffeine.Cache"
},
{
"name":"com.github.blemale.scaffeine.AsyncCache"
"name": "dev.mongocamp.driver.mongodb.Converter"
},
{
"name":"com.github.blemale.scaffeine.Cache"
"name": "dev.mongocamp.driver.mongodb.bson.BsonConverter"
}
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.mongocamp.server.cli

import dev.mongocamp.server.library.BuildInfo
import dev.mongocamp.server.service.ConfigurationRead
import lukfor.progress.TaskService
import picocli.CommandLine
import picocli.CommandLine.Help.Ansi.Style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class StartApplicationCommand extends Callable[Integer] with LazyLogging {

case s: String if s.equalsIgnoreCase("default") =>
val pluginUrls = PluginService.listOfReadableUrls().map(url => File(url))
if (pluginUrls.nonEmpty) {
// todo: reactivate build if fixed. https://github.com/oracle/graal/issues/7264
if (pluginUrls.nonEmpty || true) {
JvmStartService.startServer()
}
else {
Expand Down
6 changes: 3 additions & 3 deletions mongocamp-library/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name := "mongocamp-library"

libraryDependencies += "io.get-coursier" %% "coursier" % "2.1.7"

libraryDependencies += "dev.mongocamp" %% "mongodb-driver" % "2.6.4"
libraryDependencies += "dev.mongocamp" %% "mongodb-driver" % "2.6.5"

libraryDependencies += "io.github.classgraph" % "classgraph" % "4.8.162"
libraryDependencies += "io.github.classgraph" % "classgraph" % "4.8.163"

libraryDependencies += "com.github.blemale" %% "scaffeine" % "5.2.1" exclude("org.scala-lang.modules", "scala-java8-compat_2.12")

Expand All @@ -13,7 +13,7 @@ libraryDependencies += "io.circe" %% "circe-core" %
libraryDependencies += "io.circe" %% "circe-generic" % circeVersion
libraryDependencies += "io.circe" %% "circe-parser" % circeVersion

libraryDependencies += "com.softwaremill.sttp.model" %% "core" % "1.7.2"
libraryDependencies += "com.softwaremill.sttp.model" %% "core" % "1.7.4"

libraryDependencies += "joda-time" % "joda-time" % "2.12.5"

Expand Down
57 changes: 57 additions & 0 deletions mongocamp-library/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
server {
interface = "0.0.0.0"
port = 8080
}

cors {
origins.allowed = ["http://localhost:8080"]
headers {
allowed = ["Authorization", "Content-Type", "X-Requested-With", "X-AUTH-APIKEY"]
exposed = ["Content-Type", "x-pagination-rows-per-page", "x-pagination-current-page", "x-pagination-count-rows", "x-pagination-count-pages", "x-request-id"]
}
}

connection {
host = "localhost"
port = 27017
database = "mongocamp"
username = ""
password = ""
authdb = "admin"
}

docs {
openapi = true
swagger = false
}

auth {
handler = "mongo"
apikeylength = 32

bearer = true
token = true
basic = true
cache.db = true

users = ["{}"]
roles = ["{}"]
secret = "secret_key"
expiring.duration = 6h
prefix = "mc_"
}

file {
handler = "gridfs"
cache.age = "7776000"
}

plugins {
directory="/opt/mongocamp/plugins"
ignored=[]
modules=[]
maven.repositories=[]
urls=[]
}

http.client.headers = "{}"
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package dev.mongocamp.server.database

import com.mongodb.event.{ CommandListener, ConnectionPoolListener }
import com.mongodb.event.{CommandListener, ConnectionPoolListener}
import dev.mongocamp.driver.mongodb.bson.codecs.CustomCodecProvider
import dev.mongocamp.driver.mongodb.database.{ DatabaseProvider, MongoConfig }
import dev.mongocamp.driver.mongodb.database.{DatabaseProvider, MongoConfig}
import dev.mongocamp.server.config.DefaultConfigurations
import dev.mongocamp.server.library.BuildInfo
import dev.mongocamp.server.model.MongoCampConfiguration
import dev.mongocamp.server.service.ConfigurationRead
import org.bson.codecs.configuration.CodecProvider
import org.bson.codecs.configuration.CodecRegistries._
import org.mongodb.scala.MongoClient.DEFAULT_CODEC_REGISTRY
import org.mongodb.scala.bson.codecs.Macros._

import scala.collection.mutable.ArrayBuffer
import scala.jdk.CollectionConverters._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.mongocamp.server.model

case class MongoCampConfiguration(key: String, value: Any, configType: String, comment: String, needsRestartForActivation: Boolean) {}
case class MongoCampConfiguration(key: String, value: Any, configType: String, comment: String, needsRestartForActivation: Boolean)

object MongoCampConfiguration {
val confTypeBoolean = "Boolean"
Expand Down
Loading

0 comments on commit a522701

Please sign in to comment.