Skip to content

Commit

Permalink
ci: update version after release
Browse files Browse the repository at this point in the history
  • Loading branch information
MongoCamp CI committed Feb 13, 2024
1 parent 9b8ec50 commit 647476a
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package dev.mongocamp.server.cli

import better.files.File
import com.typesafe.scalalogging.LazyLogging
import dev.mongocamp.server.cli.service.{JvmStartService, ProcessExecutorService, ServerService}
import dev.mongocamp.server.cli.service.{ JvmStartService, ProcessExecutorService, ServerService }
import dev.mongocamp.server.service.PluginService
import picocli.CommandLine.Help.Ansi
import picocli.CommandLine.{Command, Parameters}
import picocli.CommandLine.{ Command, Parameters }

import java.util.concurrent.Callable
import scala.sys.process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dev.mongocamp.server.service.CoursierModuleService
object JvmStartService {

def startServer(): scala.sys.process.Process = {
val jars = CoursierModuleService.loadServerWithAllDependencies()
val jars = CoursierModuleService.loadServerWithAllDependencies()
val runCommand = s"${JvmService.javaHome}/bin/java -cp ${jars.mkString(":")} ${BuildInfo.mainClass}"
ProcessExecutorService.stoutProcessBuilder(runCommand)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ object ProcessExecutorService {
}
var responseString = ""
var errorString = ""
val stringProcessLogger = ProcessLogger(stout => responseString = appendString(responseString, stout), sterr => errorString = appendString(errorString, sterr))
val stringProcessLogger =
ProcessLogger(stout => responseString = appendString(responseString, stout), sterr => errorString = appendString(errorString, sterr))
val responseCode = executable.!(stringProcessLogger)
if (responseCode != 0) {
throw new RuntimeException(s"Error while executing command: $executable\n$responseString\n$errorString")
Expand All @@ -37,6 +38,7 @@ object ProcessExecutorService {
process
}

def stoutProcessLogger: ProcessLogger = ProcessLogger(stout => println(Ansi.AUTO.string(s"@|green $stout|@")), sterr => println(Ansi.AUTO.string(s"@|red $sterr|@")))
def stoutProcessLogger: ProcessLogger =
ProcessLogger(stout => println(Ansi.AUTO.string(s"@|green $stout|@")), sterr => println(Ansi.AUTO.string(s"@|red $sterr|@")))

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ object ServerService {
val jsonString = file.contentAsString
val jsonMapParseResult = decode[Map[String, String]](jsonString)
val jsonMap = jsonMapParseResult.getOrElse(throw new Exception(s"Could not parse file ${file.toString()}"))
while (System.currentTimeMillis() < jsonMap("timestamp").toLong) {
while (System.currentTimeMillis() < jsonMap("timestamp").toLong)
"wait"
}
bootServer(monitoredSystemMode)
case EventType.ENTRY_MODIFY =>
case EventType.ENTRY_DELETE =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ object MetricsConfiguration {
def addEventMeterBinder(meterBinder: MeterBinder): Unit = eventMeterBinder += meterBinder

def bindAll(): Unit = {
getJvmMetricsRegistries.foreach(r => jvmMeterBinder.foreach(_.bindTo(r)))
getSystemMetricsRegistries.foreach(r => systemMeterBinder.foreach(_.bindTo(r)))
getMongoDbMetricsRegistries.foreach(r => mongoDbMeterBinder.foreach(_.bindTo(r)))
getEventMetricsRegistries.foreach(r => eventMeterBinder.foreach(_.bindTo(r)))
getJvmMetricsRegistries.foreach(
r => jvmMeterBinder.foreach(_.bindTo(r))
)
getSystemMetricsRegistries.foreach(
r => systemMeterBinder.foreach(_.bindTo(r))
)
getMongoDbMetricsRegistries.foreach(
r => mongoDbMeterBinder.foreach(_.bindTo(r))
)
getEventMetricsRegistries.foreach(
r => eventMeterBinder.foreach(_.bindTo(r))
)
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.mongocamp.server.plugins.monitoring.metrics

import com.typesafe.scalalogging.LazyLogging
import dev.mongocamp.server.event.{Event, EventSystem}
import dev.mongocamp.server.event.{ Event, EventSystem }
import dev.mongocamp.server.plugin.ServerPlugin
import dev.mongocamp.server.plugins.monitoring.MetricsConfiguration
import io.micrometer.core.instrument.simple.SimpleMeterRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ object Metric extends LazyLogging {
.measure()
.asScala
.toList
.map(v => Measurement(validStringValue(v.getStatistic.name()), validDoubleValue(v.getValue)))
.map(
v => Measurement(validStringValue(v.getStatistic.name()), validDoubleValue(v.getValue))
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,48 @@ object MongoDbMetricsPlugin extends ServerPlugin with LazyLogging {
val registerFunctionsList: ArrayBuffer[() => Unit] = ArrayBuffer()

if (ConfigurationService.getConfigValue[Boolean](ConfKeyMetricsCommand)) {
registerFunctionsList += { () =>
{
MetricsConfiguration.getMongoDbMetricsRegistries.foreach(r => {
val commandListener = new MongoMetricsCommandListener(r)
MongoDatabase.registerCommandListener(commandListener)
})
}
registerFunctionsList += {
() =>
{
MetricsConfiguration.getMongoDbMetricsRegistries.foreach(
r => {
val commandListener = new MongoMetricsCommandListener(r)
MongoDatabase.registerCommandListener(commandListener)
}
)
}
}
}

if (ConfigurationService.getConfigValue[Boolean](ConfKeyMetricsConnectionpool)) {
registerFunctionsList += { () =>
{
MetricsConfiguration.getMongoDbMetricsRegistries.foreach(r => {
val commandListener = new MongoMetricsConnectionPoolListener(r)
MongoDatabase.registerConnectionPoolListener(commandListener)
})
}
registerFunctionsList += {
() =>
{
MetricsConfiguration.getMongoDbMetricsRegistries.foreach(
r => {
val commandListener = new MongoMetricsConnectionPoolListener(r)
MongoDatabase.registerConnectionPoolListener(commandListener)
}
)
}
}
}

ConfigurationService
.getConfigValue[List[String]](ConfKeyMetricsCollectionList)
.foreach(collection => MetricsConfiguration.addMongoDbBinder(CollectionMetrics(MongoDatabase.databaseProvider.database(), collection)))

Server.registerAfterStartCallBack(() => {
MetricsConfiguration.bindAll()
registerFunctionsList.foreach(f => f())
MongoDatabase.createNewDatabaseProvider()
})
.foreach(
collection => MetricsConfiguration.addMongoDbBinder(CollectionMetrics(MongoDatabase.databaseProvider.database(), collection))
)

Server.registerAfterStartCallBack(
() => {
MetricsConfiguration.bindAll()
registerFunctionsList.foreach(
f => f()
)
MongoDatabase.createNewDatabaseProvider()
}
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dev.mongocamp.server.route.BaseRoute
import io.circe.generic.auto._
import sttp.capabilities.WebSockets
import sttp.capabilities.pekko.PekkoStreams
import sttp.model.{Method, StatusCode}
import sttp.model.{ Method, StatusCode }
import sttp.tapir._
import sttp.tapir.json.circe.jsonBody
import sttp.tapir.server.ServerEndpoint
Expand All @@ -26,7 +26,9 @@ object MetricsRoutes extends BaseRoute with RoutesPlugin {
.description("Returns the JVM Metrics of the running MongoCamp Application")
.method(Method.GET)
.name("jvmMetrics")
.serverLogic(_ => _ => jvmMetrics())
.serverLogic(
_ => _ => jvmMetrics()
)

def jvmMetrics(): Future[Either[(StatusCode, ErrorDescription, ErrorDescription), List[Metric]]] = {
Future.successful(Right({
Expand All @@ -42,7 +44,9 @@ object MetricsRoutes extends BaseRoute with RoutesPlugin {
.description("Returns the Metrics of the MongoCamp System")
.method(Method.GET)
.name("systemMetrics")
.serverLogic(_ => _ => systemMetrics())
.serverLogic(
_ => _ => systemMetrics()
)

def systemMetrics(): Future[Either[(StatusCode, ErrorDescription, ErrorDescription), List[Metric]]] = {
Future.successful(Right({
Expand All @@ -58,7 +62,9 @@ object MetricsRoutes extends BaseRoute with RoutesPlugin {
.description("Returns the MongoDB Metrics of the running MongoCamp Application")
.method(Method.GET)
.name("mongoDbMetrics")
.serverLogic(_ => _ => mongoDbMetrics())
.serverLogic(
_ => _ => mongoDbMetrics()
)

def mongoDbMetrics(): Future[Either[(StatusCode, ErrorDescription, ErrorDescription), List[Metric]]] = {
Future.successful(Right({
Expand All @@ -74,7 +80,9 @@ object MetricsRoutes extends BaseRoute with RoutesPlugin {
.description("Returns the Metrics of events of the running MongoCamp Application.")
.method(Method.GET)
.name("eventMetrics")
.serverLogic(_ => _ => eventMetrics())
.serverLogic(
_ => _ => eventMetrics()
)

def eventMetrics(): Future[Either[(StatusCode, ErrorDescription, ErrorDescription), List[Metric]]] = {
Future.successful(Right({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ object ConfigurationRoutes extends BaseRoute with RoutesPlugin with LazyLogging
Right {
Future {
if (!force) {
val temp = File(File.temp.pathAsString + s"/mongocamp_${BuildInfo.version}")
val tmpFile = File.newTemporaryFile(parent = Some(temp))
val pid = ProcessHandle.current.pid
val temp = File(File.temp.pathAsString + s"/mongocamp_${BuildInfo.version}")
val tmpFile = File.newTemporaryFile(parent = Some(temp))
val pid = ProcessHandle.current.pid
val shutdownTimestamp = System.currentTimeMillis() + 1.seconds.toMillis
tmpFile.write("{\"event\":\"shutdown\",\"timestamp\":\"" + shutdownTimestamp + "\",\"pid\":\"" + pid + "\"}")
tmpFile.appendLine()
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "mongocamp-server",
"organization" : "dev.mongocamp",
"version" : "1.5.10",
"version" : "1.5.11.snapshot",
"description" : "",
"directories" : {
"doc" : "docs"
Expand Down

0 comments on commit 647476a

Please sign in to comment.