Compare commits
2 commits
4b60f59956
...
b5791e784b
Author | SHA1 | Date | |
---|---|---|---|
b5791e784b | |||
f3bcd64a90 |
3 changed files with 15 additions and 5 deletions
|
@ -8,6 +8,7 @@ services:
|
||||||
context: .
|
context: .
|
||||||
target: bot
|
target: bot
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
user: 1000:1000
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- migration
|
- migration
|
||||||
|
@ -21,6 +22,7 @@ services:
|
||||||
context: .
|
context: .
|
||||||
target: web
|
target: web
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
user: 1000:1000
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- migration
|
- migration
|
||||||
|
@ -35,6 +37,7 @@ services:
|
||||||
dockerfile: Containerfile
|
dockerfile: Containerfile
|
||||||
context: .
|
context: .
|
||||||
target: migration
|
target: migration
|
||||||
|
user: 1000:1000
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import de.hhhammer.dchat.db.ServerDBService;
|
import de.hhhammer.dchat.db.ServerDBService;
|
||||||
import de.hhhammer.dchat.db.UserDBService;
|
import de.hhhammer.dchat.db.UserDBService;
|
||||||
import io.javalin.Javalin;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -30,9 +29,6 @@ public class App {
|
||||||
config.setJdbcUrl(postgresUrl);
|
config.setJdbcUrl(postgresUrl);
|
||||||
config.setUsername(postgresUser);
|
config.setUsername(postgresUser);
|
||||||
config.setPassword(postgresPassword);
|
config.setPassword(postgresPassword);
|
||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
|
||||||
|
|
||||||
try (var ds = new HikariDataSource(config)) {
|
try (var ds = new HikariDataSource(config)) {
|
||||||
var serverDBService = new ServerDBService(ds);
|
var serverDBService = new ServerDBService(ds);
|
||||||
|
|
|
@ -10,6 +10,9 @@ import io.javalin.http.staticfiles.Location;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static io.javalin.apibuilder.ApiBuilder.crud;
|
import static io.javalin.apibuilder.ApiBuilder.crud;
|
||||||
import static io.javalin.apibuilder.ApiBuilder.path;
|
import static io.javalin.apibuilder.ApiBuilder.path;
|
||||||
|
|
||||||
|
@ -38,9 +41,12 @@ public class WebAPI implements Runnable {
|
||||||
staticFileConfig.directory = "ui";
|
staticFileConfig.directory = "ui";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
var waitForShutdown = new CompletableFuture<Void>();
|
||||||
|
Runtime.getRuntime().addShutdownHook(Thread.ofVirtual().name("javalin-shutdown").unstarted(() -> {
|
||||||
logger.info("Shutting down web application");
|
logger.info("Shutting down web application");
|
||||||
app.stop();
|
app.stop();
|
||||||
|
waitForShutdown.complete(null);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
app.events(event -> {
|
app.events(event -> {
|
||||||
event.serverStopping(() -> logger.info("Stopping web service"));
|
event.serverStopping(() -> logger.info("Stopping web service"));
|
||||||
|
@ -69,5 +75,10 @@ public class WebAPI implements Runnable {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.start(this.port);
|
app.start(this.port);
|
||||||
|
try {
|
||||||
|
waitForShutdown.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue