making backend version public
This commit is contained in:
parent
fde4b2455f
commit
984d852178
|
@ -1,8 +1,35 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20200723;
|
public static final int CONSOLE_VERSION = 20200723;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
|
|
||||||
|
public static long classBuildTimeMillis() {
|
||||||
|
Class<?> clazz = rusEFIVersion.class;
|
||||||
|
URL resource = clazz.getResource(clazz.getSimpleName() + ".class");
|
||||||
|
if (resource == null) {
|
||||||
|
throw new IllegalStateException("Failed to find class file for class: " +
|
||||||
|
clazz.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resource.getProtocol().equals("file")) {
|
||||||
|
try {
|
||||||
|
return new File(resource.toURI()).lastModified();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else if (resource.getProtocol().equals("jar")) {
|
||||||
|
String path = resource.getPath();
|
||||||
|
return new File(path.substring(5, path.indexOf("!"))).lastModified();
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unhandled url protocol: " +
|
||||||
|
resource.getProtocol() + " for class: " +
|
||||||
|
clazz.getName() + " resource: " + resource.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class Launcher extends rusEFIVersion {
|
||||||
*/
|
*/
|
||||||
public static void main(final String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
log.info("rusEFI UI console " + CONSOLE_VERSION);
|
log.info("rusEFI UI console " + CONSOLE_VERSION);
|
||||||
log.info("Compiled " + new Date(ConsoleTools.classBuildTimeMillis()));
|
log.info("Compiled " + new Date(rusEFIVersion.classBuildTimeMillis()));
|
||||||
log.info("\n\n");
|
log.info("\n\n");
|
||||||
PersistentConfiguration.registerShutdownHook();
|
PersistentConfiguration.registerShutdownHook();
|
||||||
|
|
||||||
|
|
|
@ -292,26 +292,6 @@ public class ConsoleTools {
|
||||||
Online.upload(new File(Online.outputXmlFileName), authToken);
|
Online.upload(new File(Online.outputXmlFileName), authToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long classBuildTimeMillis() throws URISyntaxException, IllegalStateException, IllegalArgumentException {
|
|
||||||
Class<?> clazz = ConsoleTools.class;
|
|
||||||
URL resource = clazz.getResource(clazz.getSimpleName() + ".class");
|
|
||||||
if (resource == null) {
|
|
||||||
throw new IllegalStateException("Failed to find class file for class: " +
|
|
||||||
clazz.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resource.getProtocol().equals("file")) {
|
|
||||||
return new File(resource.toURI()).lastModified();
|
|
||||||
} else if (resource.getProtocol().equals("jar")) {
|
|
||||||
String path = resource.getPath();
|
|
||||||
return new File(path.substring(5, path.indexOf("!"))).lastModified();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Unhandled url protocol: " +
|
|
||||||
resource.getProtocol() + " for class: " +
|
|
||||||
clazz.getName() + " resource: " + resource.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void detect(String[] strings) throws IOException, InterruptedException {
|
static void detect(String[] strings) throws IOException, InterruptedException {
|
||||||
String autoDetectedPort = autoDetectPort();
|
String autoDetectedPort = autoDetectPort();
|
||||||
if (autoDetectedPort == null) {
|
if (autoDetectedPort == null) {
|
||||||
|
|
|
@ -96,15 +96,14 @@ public class Backend implements Closeable {
|
||||||
new Monitoring(this).showStatistics,
|
new Monitoring(this).showStatistics,
|
||||||
new FkRegex(ProxyClient.VERSION_PATH, ProxyClient.BACKEND_VERSION),
|
new FkRegex(ProxyClient.VERSION_PATH, ProxyClient.BACKEND_VERSION),
|
||||||
new FkRegex("/", new RsHtml("<html><body>\n" +
|
new FkRegex("/", new RsHtml("<html><body>\n" +
|
||||||
"<a href='https://rusefi.com/online/'>rusEFI Online</a>\n" +
|
"<br/><a href='https://rusefi.com/online/'>rusEFI Online</a>\n" +
|
||||||
"<br/>\n" +
|
"<br/><br/><br/>\n" +
|
||||||
"<a href='" + Monitoring.STATUS + "'>Status</a>\n" +
|
"<img src='https://rusefi.com/style/rusefi_online_color.png'/>" +
|
||||||
"<br/>\n" +
|
"<br/><br/><br/>\n" +
|
||||||
"<a href='" + ProxyClient.VERSION_PATH + "'>Version</a>\n" +
|
"<br/><br/><br/><a href='" + Monitoring.STATUS + "'>Status</a>\n" +
|
||||||
"<a href='" + ProxyClient.LIST_CONTROLLERS_PATH + "'>Controllers</a>\n" +
|
"<br/><br/><br/><a href='" + ProxyClient.VERSION_PATH + "'>Version</a>\n" +
|
||||||
"<a href='" + ProxyClient.LIST_APPLICATIONS_PATH + "'>Applications</a>\n" +
|
"<br/><br/><br/><a href='" + ProxyClient.LIST_CONTROLLERS_PATH + "'>Controllers</a>\n" +
|
||||||
"<br/>\n" +
|
"<br/><br/><br/><a href='" + ProxyClient.LIST_APPLICATIONS_PATH + "'>Applications</a>\n" +
|
||||||
"<br/>\n" +
|
|
||||||
"</body></html>\n"))
|
"</body></html>\n"))
|
||||||
), httpPort
|
), httpPort
|
||||||
).start(() -> isClosed);
|
).start(() -> isClosed);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.rusefi.server;
|
package com.rusefi.server;
|
||||||
|
|
||||||
|
import com.rusefi.rusEFIVersion;
|
||||||
|
import com.rusefi.tools.online.ProxyClient;
|
||||||
import org.takes.Take;
|
import org.takes.Take;
|
||||||
import org.takes.facets.fork.FkRegex;
|
import org.takes.facets.fork.FkRegex;
|
||||||
import org.takes.rs.RsJson;
|
import org.takes.rs.RsJson;
|
||||||
|
@ -9,6 +11,7 @@ import javax.json.JsonObjectBuilder;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.management.OperatingSystemMXBean;
|
import java.lang.management.OperatingSystemMXBean;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class Monitoring {
|
public class Monitoring {
|
||||||
public static final String STATUS = "/status";
|
public static final String STATUS = "/status";
|
||||||
|
@ -39,6 +42,9 @@ public class Monitoring {
|
||||||
builder.add("serverPortForControllers", backend.serverPortForControllers);
|
builder.add("serverPortForControllers", backend.serverPortForControllers);
|
||||||
builder.add("applicationsCount", backend.getApplicationsCount());
|
builder.add("applicationsCount", backend.getApplicationsCount());
|
||||||
builder.add("controllersCount", backend.getControllersCount());
|
builder.add("controllersCount", backend.getControllersCount());
|
||||||
|
builder.add("backend version", ProxyClient.BACKEND_VERSION);
|
||||||
|
builder.add("framework version", rusEFIVersion.CONSOLE_VERSION);
|
||||||
|
builder.add("compiled", new Date(rusEFIVersion.classBuildTimeMillis()).toString());
|
||||||
|
|
||||||
return new RsJson(builder.build());
|
return new RsJson(builder.build());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue