32 lines
1.1 KiB
Java
32 lines
1.1 KiB
Java
package eu.jonahbauer.chat.server;
|
|
|
|
import eu.jonahbauer.chat.server.bot.ChatBotSupervisor;
|
|
import eu.jonahbauer.chat.server.socket.SocketSupervisor;
|
|
import eu.jonahbauer.chat.server.util.Lazy.MutableLazy;
|
|
|
|
import javax.management.JMException;
|
|
import java.io.IOException;
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) throws IOException, InterruptedException, JMException {
|
|
var config = Config.load();
|
|
var chatBotSupervisorLazy = new MutableLazy<ChatBotSupervisor>();
|
|
var socketSupervisorLazy = new MutableLazy<SocketSupervisor>();
|
|
try (
|
|
var chatBotSupervisor = chatBotSupervisorLazy.set(new ChatBotSupervisor(socketSupervisorLazy));
|
|
var socketSupervisor = socketSupervisorLazy.set(new SocketSupervisor(chatBotSupervisorLazy))
|
|
) {
|
|
chatBotSupervisor.start(config);
|
|
socketSupervisor.start(config);
|
|
|
|
try {
|
|
// keep main thread running
|
|
new CountDownLatch(1).await();
|
|
} catch (InterruptedException _) {
|
|
// ignore
|
|
}
|
|
}
|
|
}
|
|
} |