diff --git a/Dockerfile b/Dockerfile index b468f15..067fa02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,24 +6,30 @@ WORKDIR /root RUN apk update RUN apk add make \ bash \ + openjdk21-jdk \ curl \ openssl-dev \ python3-dev \ gmp-dev \ tar -RUN apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing criu-dev \ - openjdk20-jre-headless +RUN apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/criu-dev +RUN apk add tar + +COPY . . + +#ADD / +#ADD *.jar Node.jar +#ADD config.json config.json +#ADD vdf-cli vdf-cli +#ADD Start.sh Start.sh +#ADD SaveContainer.sh SaveContainer.sh +#ADD RunContainer.sh RunContainer.sh -ADD *.jar Node.jar -ADD config.json config.json -ADD vdf-cli vdf-cli -ADD Start.sh Start.sh -ADD SaveContainer.sh SaveContainer.sh -ADD RunContainer.sh RunContainer.sh # ADD stress.sh stress.sh # COPY stress.tar stress.tar +RUN ./gradlew assemble jar RUN chmod 777 Start.sh RUN chmod 777 vdf-cli RUN mv vdf-cli /usr/bin/vdf-cli diff --git a/Start.sh b/Start.sh index 8a25108..7b9284e 100644 --- a/Start.sh +++ b/Start.sh @@ -1,20 +1,21 @@ #!/bin/bash -if [ "$#" -ne 1 ]; then -echo "Sleeping..." -# sleep $(shuf -i 1-120 -n 1) -fi +#if [ "$#" -ne 1 ]; then +#echo "Sleeping..." +#sleep $(shuf -i 1-120 -n 1) +#fi + +#dockerd --experimental & +#while [ ! -f /var/run/docker.pid ] +#do +#echo "Waiting for docker daemon to initialize!" +#sleep 5 +#done -dockerd --experimental & -while [ ! -f /var/run/docker.pid ] -do -echo "Waiting for docker daemon to initialize!" -sleep 5 -done +#docker load -i stress.tar -# docker load -i stress.tar -# if [ "$1" -eq 5005 ]; then -# echo "We're trusted. Running stress test." -# bash stress.sh & -# fi +if [ "$1" -eq 5005 ]; then + echo "We're trusted. Running stress test." +# bash stress.sh & +fi -java -jar Node.jar $1 \ No newline at end of file +java -jar build/libs/nion-core.jar $1 $2 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 68897e2..11f444f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,43 +1,45 @@ plugins { id 'java' - id("org.jetbrains.kotlin.jvm") version "1.9.0" - id("org.jetbrains.kotlin.plugin.serialization") version "1.9.0" + id("org.jetbrains.kotlin.jvm") version "2.2.0" + id("org.jetbrains.kotlin.plugin.serialization") version "2.2.0" } group 'nion.network' -version '0.1' - -configurations.implementation.setCanBeResolved(true) +//version '0.1' +//configurations.implementation.setCanBeResolved(true) repositories { mavenCentral() } dependencies { - testImplementation('org.junit.jupiter:junit-jupiter-api:5.8.1') - testImplementation('org.junit.jupiter:junit-jupiter-engine:5.8.1') + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2") + testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.2") + - implementation('org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0') + implementation('org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.0') implementation('org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.3.0') implementation('org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0') - implementation("com.influxdb:influxdb-client-kotlin:4.0.0") + implementation("com.influxdb:influxdb-client-kotlin:7.3.0") implementation('org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt') implementation("io.javalin:javalin:5.6.1") implementation("org.slf4j:slf4j-simple:2.0.7") } -tasks.withType(Test).configureEach { - it.scanForTestClasses = false - it.useJUnitPlatform() +tasks.test { + useJUnitPlatform() + scanForTestClasses = false + failOnNoDiscoveredTests = false } - tasks.jar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE - setArchivesBaseName("Nion-Network") + archiveBaseName.set("nion-core") manifest { attributes.put("Main-Class", "LaunchKt") } - from { - configurations.implementation.collect { it.isDirectory() ? it : zipTree(it) } - } + dependsOn(configurations.runtimeClasspath) + from({ + configurations.runtimeClasspath + .collect { it.isDirectory() ? it : zipTree(it) } + }) } \ No newline at end of file diff --git a/config.json b/config.json index 8003d52..c8296b0 100644 --- a/config.json +++ b/config.json @@ -11,7 +11,7 @@ "influxUrl": "http://88.200.63.190:8086", "influxToken": "LtudFFrFu_b91XO6bCr0mzJuKV-Ffzom2phPlbn9FqNgDiYYcFRmh0mt63sHwPTo7JUv3jCe9RQNmB4AHMpKbQ==", "dashboardEnabled": false, - "loggingEnabled": false, + "loggingEnabled": true, "trustedLoggingEnabled": false, "historyMinuteClearance": 1, "historyCleaningFrequency": 1, @@ -21,4 +21,4 @@ "useCriu": true, "useTreeBasedMessageRoutingProtocol": true, "treeChildrenCount": 2 -} \ No newline at end of file +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5d0f28c..5459771 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists # Could be upgraded to 8.3, depending on the user needs. \ No newline at end of file diff --git a/src/main/kotlin/Launch.kt b/src/main/kotlin/Launch.kt index 32ceb7f..82c1686 100644 --- a/src/main/kotlin/Launch.kt +++ b/src/main/kotlin/Launch.kt @@ -3,7 +3,6 @@ import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json import logging.Logger import utils.tryAndReport -import java.io.File /** * Created by Mihael Valentin Berčič @@ -13,8 +12,11 @@ import java.io.File @ExperimentalSerializationApi fun main(args: Array) { tryAndReport { - System.setProperty("kotlinx.coroutines.scheduler", "off") // Needed due to bugs with linux and docker containers. TODO: fix ASAP - val configuration = Json.decodeFromString(File("./config.json").readText()) + System.setProperty("kotlinx.coroutines.scheduler", "off") + + val passedConfiguration = args.getOrNull(1) ?: throw Exception("Configuration should be passed to the docker container.") + val configuration = Json.decodeFromString(passedConfiguration) + Logger.toggleLogging(configuration.loggingEnabled) args.getOrNull(0)?.toInt()?.apply { configuration.port = this diff --git a/src/main/kotlin/network/data/messages/Message.kt b/src/main/kotlin/network/data/messages/Message.kt index 30ad040..6181f04 100644 --- a/src/main/kotlin/network/data/messages/Message.kt +++ b/src/main/kotlin/network/data/messages/Message.kt @@ -1,5 +1,8 @@ +@file:OptIn(ExperimentalSerializationApi::class) + package network.data.messages +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromByteArray import kotlinx.serialization.protobuf.ProtoBuf