29 lines
968 B
Java
29 lines
968 B
Java
package vn.sis.appointment;
|
|
|
|
public final class Application {
|
|
private Application() {
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
int port = resolvePort();
|
|
AppointmentWebServer server = new AppointmentWebServer(port);
|
|
server.start();
|
|
|
|
System.out.printf("S.I.S Appointment Java Web dang chay tai http://localhost:%d%n", port);
|
|
System.out.println("Nhan Ctrl+C de dung ung dung.");
|
|
}
|
|
|
|
private static int resolvePort() {
|
|
String value = System.getenv().getOrDefault("PORT", "8080").trim();
|
|
try {
|
|
int port = Integer.parseInt(value);
|
|
if (port < 1 || port > 65535) {
|
|
throw new IllegalArgumentException("PORT phai nam trong khoang 1-65535.");
|
|
}
|
|
return port;
|
|
} catch (NumberFormatException ex) {
|
|
throw new IllegalArgumentException("Bien moi truong PORT khong hop le: " + value, ex);
|
|
}
|
|
}
|
|
}
|