added Graal native image build for the server
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package net.woggioni.gbcs.graal;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class ConfigureNativeServer {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
NativeServer.run(Duration.ofSeconds(60));
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package net.woggioni.gbcs.graal;
|
||||
|
||||
import net.woggioni.gbcs.server.GradleBuildCacheServer;
|
||||
import net.woggioni.jwo.Application;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
|
||||
public class NativeServer {
|
||||
|
||||
private static Path findConfigurationFile(Application app, String fileName) {
|
||||
final var confDir = app.computeConfigurationDirectory();
|
||||
final var configurationFile = confDir.resolve(fileName);
|
||||
return configurationFile;
|
||||
}
|
||||
|
||||
static void run(Duration timeout) throws Exception {
|
||||
final var app = Application.builder("gbcs")
|
||||
.configurationDirectoryEnvVar("GBCS_CONFIGURATION_DIR")
|
||||
.configurationDirectoryPropertyKey("net.woggioni.gbcs.conf.dir")
|
||||
.build();
|
||||
|
||||
final var configurationFile = findConfigurationFile(app, "gbcs-server.xml");
|
||||
final var cfg = GradleBuildCacheServer.Companion.loadConfiguration(configurationFile);
|
||||
try(final var handle = new GradleBuildCacheServer(cfg).run()) {
|
||||
if(timeout != null) {
|
||||
Thread.sleep(timeout);
|
||||
handle.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPropertyIfNotPresent(String key, String value) {
|
||||
final var previousValue = System.getProperty(key);
|
||||
if(previousValue == null) {
|
||||
System.setProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
setPropertyIfNotPresent("logback.configurationFile", "net/woggioni/gbcs/graal/logback.xml");
|
||||
setPropertyIfNotPresent("io.netty.leakDetectionLevel", "DISABLED");
|
||||
run(null);
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration>
|
||||
|
||||
<configuration>
|
||||
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/>
|
||||
<import class="ch.qos.logback.core.ConsoleAppender"/>
|
||||
|
||||
<appender name="console" class="ConsoleAppender">
|
||||
<target>System.err</target>
|
||||
<encoder class="PatternLayoutEncoder">
|
||||
<pattern>%d [%highlight(%-5level)] \(%thread\) %logger{36} -%kvp- %msg %n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
</configuration>
|
Reference in New Issue
Block a user