console start-up is now 0.9 second faster

This commit is contained in:
rusefi 2020-05-21 00:51:36 -04:00
parent a4f8434f10
commit 33b98db71d
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.rusefi.ui.util; package com.rusefi.ui.util;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
@ -12,10 +13,12 @@ import java.net.Socket;
*/ */
public class JustOneInstance { public class JustOneInstance {
private static final int PORT = 29212; private static final int PORT = 29212;
private static final int LOCAL_CONNECTION_TIMEOUT_MS = 100;
public static boolean isAlreadyRunning() { public static boolean isAlreadyRunning() {
try { try {
Socket clientSocket = new Socket("localhost", PORT); Socket clientSocket = new Socket();
clientSocket.connect(new InetSocketAddress("localhost", PORT), LOCAL_CONNECTION_TIMEOUT_MS);
System.out.println("*** Already running!"); System.out.println("*** Already running!");
return true; return true;
} catch (IOException e) { } catch (IOException e) {