Too much of "Looks like another instance is already running." #5584

This commit is contained in:
rusefi 2023-09-25 16:57:24 -04:00
parent 01372c9bb6
commit d6da0c3ce0
2 changed files with 11 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import java.net.URL;
import java.util.concurrent.atomic.AtomicReference;
public class rusEFIVersion {
public static final int CONSOLE_VERSION = 20230917;
public static final int CONSOLE_VERSION = 20230925;
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
public static long classBuildTimeMillis() {

View File

@ -1,13 +1,14 @@
package com.rusefi.ui.util;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
/**
* This class is used to figure out if we have multiple instances of rusEfi console running
*
* <p>
* Andrey Belomutskiy, (c) 2013-2020
* 5/4/2015
*/
@ -39,8 +40,7 @@ public class JustOneInstance {
while (true) {
// Wait for a connection
Socket clientSocket = serverSocket.accept();
// System.out.println("*** Got a connection! ");
clientSocket.close();
handleConnection(clientSocket);
}
} catch (IOException e) {
}
@ -48,4 +48,11 @@ public class JustOneInstance {
};
new Thread(runnable, "JustOneInstance").start();
}
private static void handleConnection(Socket clientSocket) throws IOException {
try (clientSocket) {
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
out.println(new java.util.Date() + "Already running " + ProcessHandle.current().pid() + "\r\n");
}
}
}