set up the router in advance and run it with runRouter instead of RouterLaunch.main

This commit is contained in:
idk
2022-09-11 17:10:04 -04:00
parent 5cbf441715
commit 09af24a115

View File

@ -32,7 +32,9 @@ import net.i2p.util.SystemVersion;
*/ */
public class WinLauncher { public class WinLauncher {
static Logger logger = Logger.getLogger("launcherlog"); static Logger logger = Logger.getLogger("launcherlog");
static WindowsUpdatePostProcessor wupp = null;
static FileHandler fh; static FileHandler fh;
private static Router i2pRouter;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
setupLauncher(); setupLauncher();
@ -119,7 +121,7 @@ public class WinLauncher {
*/ */
System.setProperty("user.dir", programs.getAbsolutePath()); System.setProperty("user.dir", programs.getAbsolutePath());
// wupp.i2pRouter = new Router(System.getProperties()); i2pRouter = new Router(System.getProperties());
logger.info("Router is configured"); logger.info("Router is configured");
Thread registrationThread = new Thread(REGISTER_UPP); Thread registrationThread = new Thread(REGISTER_UPP);
@ -128,8 +130,13 @@ public class WinLauncher {
registrationThread.start(); registrationThread.start();
setNotStarting(); setNotStarting();
// wupp.i2pRouter.runRouter(); // TODO: I actually did this once before, and reversed it for
RouterLaunch.main(args); // some dumb reason I can't remember. But if I go back through
// all the steps then I set up the router before I run it ^^
// see above commented out `wupp` and I don't have to wait for
// certain contexts to be ready anymore.
i2pRouter.runRouter();
// RouterLaunch.main(args);
} }
private static void setupLauncher() { private static void setupLauncher() {
@ -146,7 +153,7 @@ public class WinLauncher {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
File jrehome = javaHome(); File jrehome = javaHome();
logger.info("jre home is: " + jrehome.getAbsolutePath()); logger.info("jre home is: " + jrehome.getAbsolutePath());
File appimagehome = appImageHome(); File appimagehome = appImageHome();
@ -298,9 +305,8 @@ public class WinLauncher {
} }
private static final Runnable REGISTER_UPP = () -> { private static final Runnable REGISTER_UPP = () -> {
// first wait for the RouterContext to appear
RouterContext ctx; RouterContext ctx;
while ((ctx = (RouterContext)RouterContext.getCurrentContext()) == null) { while ((ctx = i2pRouter.getContext()) == null) {
sleep(1000); sleep(1000);
} }
// then wait for the update manager // then wait for the update manager