39 lines
1.4 KiB
Java
39 lines
1.4 KiB
Java
package de.tudbut.tryumph;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import de.tudbut.tryumph.config.IRequestCatcher;
|
|
import de.tudbut.tryumph.config.RequestCatcherConfig;
|
|
import de.tudbut.tryumph.config.TryConfig;
|
|
import de.tudbut.tryumph.err.ProjectException;
|
|
import de.tudbut.tryumph.server.http.Server;
|
|
import de.tudbut.tryumph.util.Bug;
|
|
|
|
public class Launch {
|
|
|
|
private static TryConfig config;
|
|
private static RequestCatcherConfig[] catchers;
|
|
|
|
public static void main(String[] args) throws ProjectException, InterruptedException {
|
|
try {
|
|
config = new TryConfig(args, Launch.class.getClassLoader().getResourceAsStream("config.try"));
|
|
catchers = config.getCatchers().ok().await();
|
|
} catch(Exception e) {
|
|
throw new ProjectException("Error loading project", e);
|
|
}
|
|
System.out.println(Arrays.toString(catchers));
|
|
for(int i = 0; i < catchers.length; i++) {
|
|
try {
|
|
RequestCatcherConfig catcher = catchers[i];
|
|
Server server = new Server(catcher.getPort().ok().await());
|
|
IRequestCatcher requestCatcher = catcher.load().ok().await();
|
|
server.listen(requestCatcher);
|
|
} catch(Throwable e) {
|
|
throw new Bug("HTTP server died, but all errors from HTTP should usually be catched", e);
|
|
}
|
|
}
|
|
|
|
Thread.sleep(1000);
|
|
System.exit(0);
|
|
}
|
|
}
|