proxy progress

This commit is contained in:
rusefi 2020-07-18 17:02:31 -04:00
parent 481ca76dc1
commit 7eec613a9c
4 changed files with 15 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import org.takes.Take;
import org.takes.facets.fork.FkRegex;
import org.takes.facets.fork.TkFork;
import org.takes.http.FtBasic;
import org.takes.rs.RsHtml;
import org.takes.rs.RsJson;
import javax.json.Json;
@ -21,6 +22,7 @@ import javax.json.JsonObject;
import java.io.IOException;
import java.net.Socket;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
public class Backend {
@ -42,6 +44,7 @@ public class Backend {
// private final int clientTimeout;
private final UserDetailsResolver userDetailsResolver;
private final Logger logger;
public final static AtomicLong totalSessions = new AtomicLong();
public Backend(UserDetailsResolver userDetailsResolver, int httpPort, Logger logger) {
// this.clientTimeout = clientTimeout;
@ -56,7 +59,11 @@ public class Backend {
new TkFork(showOnlineUsers,
Monitoring.showStatistics,
new FkRegex(VERSION_PATH, BACKEND_VERSION),
new FkRegex("/", "<a href='https://rusefi.com/online/'>rusEFI Online</a>")
new FkRegex("/", new RsHtml("<html><body>\n" +
"<a href='https://rusefi.com/online/'>rusEFI Online</a>\n" +
"<br/>\n" +
"<a href='/status'>Status</a>\n" +
"</body></html>\n"))
), httpPort
).start(() -> isClosed);
logger.info("Shutting down backend on port " + httpPort);
@ -85,6 +92,7 @@ public class Backend {
return new Runnable() {
@Override
public void run() {
totalSessions.incrementAndGet();
// connection from authenticator app which proxies for Tuner Studio
IoStream applicationClientStream = null;
try {
@ -136,6 +144,7 @@ public class Backend {
return new Runnable() {
@Override
public void run() {
totalSessions.incrementAndGet();
ControllerConnectionState controllerConnectionState = new ControllerConnectionState(controllerSocket, logger, getUserDetailsResolver());
try {
controllerConnectionState.requestControllerInfo();

View File

@ -27,6 +27,8 @@ public class Monitoring {
builder.add("CPU_Load", operatingSystemMXBean.getSystemLoadAverage());
builder.add("free_ram", formatSize(Runtime.getRuntime().freeMemory()));
builder.add("max_ram", formatSize(Runtime.getRuntime().maxMemory()));
builder.add("threads", Thread.getAllStackTraces().size());
builder.add("sessions", Backend.totalSessions.get());
return new RsJson(builder.build());
}

View File

@ -13,13 +13,14 @@
<javac debug="yes"
destdir="build/classes"
classpath="${console_path}/lib/jSerialComm.jar:${console_path}/lib/junit.jar:${console_path}/lib/json-simple-1.1.1.jar:${console_path}/lib/annotations.jar:${launcher_path}/lib/TunerStudioPluginAPI.jar:${console_path}/lib/httpclient.jar:${console_path}/lib/httpmime.jar:${console_path}/lib/httpcore.jar"
classpath="${console_path}/lib/jcip-annotations-1.0.jar:${console_path}/lib/annotations.jar:${console_path}/lib/jSerialComm.jar:${console_path}/lib/junit.jar:${console_path}/lib/json-simple-1.1.1.jar:${console_path}/lib/annotations.jar:${launcher_path}/lib/TunerStudioPluginAPI.jar:${console_path}/lib/httpclient.jar:${console_path}/lib/httpmime.jar:${console_path}/lib/httpcore.jar"
>
<src path="${console_path}/shared_ui/src"/>
<src path="${console_path}/autoupdate/src"/>
<src path="${console_path}/shared_io/src/main/java"/>
<src path="${console_path}/inifile/src"/>
<src path="${console_path}/logging/src"/>
<src path="${console_path}/io/src/main/java"/>
<src path="${console_path}/logging-api/src/main/java"/>
<src path="${console_path}/models/src"/>
<src path="${launcher_path}/src"/>

View File

@ -4,6 +4,7 @@
<modules>
<module fileurl="file://$PROJECT_DIR$/../../java_console/autoupdate/autoupdate.iml" filepath="$PROJECT_DIR$/../../java_console/autoupdate/autoupdate.iml" />
<module fileurl="file://$PROJECT_DIR$/../../java_console/inifile/inifile.iml" filepath="$PROJECT_DIR$/../../java_console/inifile/inifile.iml" />
<module fileurl="file://$PROJECT_DIR$/../../java_console/io/io.iml" filepath="$PROJECT_DIR$/../../java_console/io/io.iml" />
<module fileurl="file://$PROJECT_DIR$/../../java_console/logging/logging.iml" filepath="$PROJECT_DIR$/../../java_console/logging/logging.iml" />
<module fileurl="file://$PROJECT_DIR$/../../java_console/logging-api/logging-api.iml" filepath="$PROJECT_DIR$/../../java_console/logging-api/logging-api.iml" />
<module fileurl="file://$PROJECT_DIR$/../../java_console/models/models.iml" filepath="$PROJECT_DIR$/../../java_console/models/models.iml" />