Skip to content

Commit

Permalink
delay starting non-essential threads
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Sep 28, 2024
1 parent 6dd2202 commit f26bd5c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/app/attestation/server/AttestationServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class AttestationServer {
static final String DOMAIN = "attestation.app";
private static final String ORIGIN = "https://" + DOMAIN;

private static final long POST_START_DELAY_MS = 1000;

private static final Logger logger = Logger.getLogger(AttestationServer.class.getName());

// This should be moved to a table in the database so that it can be modified dynamically
Expand Down Expand Up @@ -478,7 +480,6 @@ INSERT INTO Attestations (
}

final ThreadPoolExecutor executor = new ThreadPoolExecutor(32, 32, 0, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(1024));
executor.prestartAllCoreThreads();

System.setProperty("sun.net.httpserver.nodelay", "true");
final HttpServer server = HttpServer.create(new InetSocketAddress("::1", 8080), 4096);
Expand All @@ -501,6 +502,13 @@ INSERT INTO Attestations (
server.setExecutor(executor);
server.start();

try {
Thread.sleep(POST_START_DELAY_MS);
} catch (final InterruptedException e) {
return;
}

executor.prestartAllCoreThreads();
new Thread(new AlertDispatcher()).start();
new Thread(new Maintenance()).start();
}
Expand Down

0 comments on commit f26bd5c

Please sign in to comment.