Compare commits

..

No commits in common. "b5791e784b0306ca5e1c7aadf65efd0c1f267355" and "4b60f599566647ccb64f2c853130d559c586b48a" have entirely different histories.

3 changed files with 5 additions and 15 deletions

View file

@ -8,7 +8,6 @@ services:
context: . context: .
target: bot target: bot
restart: unless-stopped restart: unless-stopped
user: 1000:1000
depends_on: depends_on:
- db - db
- migration - migration
@ -22,7 +21,6 @@ services:
context: . context: .
target: web target: web
restart: unless-stopped restart: unless-stopped
user: 1000:1000
depends_on: depends_on:
- db - db
- migration - migration
@ -37,7 +35,6 @@ services:
dockerfile: Containerfile dockerfile: Containerfile
context: . context: .
target: migration target: migration
user: 1000:1000
depends_on: depends_on:
- db - db

View file

@ -4,6 +4,7 @@ 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;
@ -29,6 +30,9 @@ 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);

View file

@ -10,9 +10,6 @@ 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;
@ -41,12 +38,9 @@ public class WebAPI implements Runnable {
staticFileConfig.directory = "ui"; staticFileConfig.directory = "ui";
}); });
}); });
var waitForShutdown = new CompletableFuture<Void>(); Runtime.getRuntime().addShutdownHook(new Thread(() -> {
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"));
@ -75,10 +69,5 @@ public class WebAPI implements Runnable {
}); });
app.start(this.port); app.start(this.port);
try {
waitForShutdown.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
} }
} }