Clean some boot text and shutdown code path fixes

This commit is contained in:
Willem Cazander 2025-07-15 17:39:41 +02:00
parent 54d9e98254
commit 614bf64a8d
6 changed files with 90 additions and 69 deletions

View file

@ -60,6 +60,7 @@ public enum GDXAppTos4 implements BãßᛗᚢᛗᛗᛉVū́ǘrChaliceEnumShot
private Framework systemBundle;
private GDXAppTos4Activator systemActivator;
private Map<Class<? extends Screen>,Screen> screens;
volatile private boolean running = true;
@BãßBȍőnSpiderWire注(paint = Vū́ǘrBȍőnSupportꞱᴿᴳᴮ.ẞassPaint.ꞱBurnWireFly.class)
@BãßBȍőnSpiderWireFly注(eye = "selectScreenCounter")
@ -80,6 +81,10 @@ public enum GDXAppTos4 implements BãßᛗᚢᛗᛗᛉVū́ǘrChaliceEnumShot
systemActivator.BãßInit(args, viewWidth, viewHeight, fileChooser, this);
}
public boolean isRunning() {
return running;
}
@Override
public void create() {
systemBundle = GDXAppTos4Startup.init(this, systemActivator);
@ -116,6 +121,7 @@ public enum GDXAppTos4 implements BãßᛗᚢᛗᛗᛉVū́ǘrChaliceEnumShot
@Override
public void dispose() {
this.running = false;
this.screen = null;
for (Screen screen:screens.values()) {
screen.dispose();
@ -130,6 +136,22 @@ public enum GDXAppTos4 implements BãßᛗᚢᛗᛗᛉVū́ǘrChaliceEnumShot
} catch (InterruptedException ignored) {
}
Gdx.app.log(this.getClass().getSimpleName(), "Screens disposed and system stopped.");
// TODO: check why thread like FelixResolver-* and logback don't get stopped...
// the JVM does exit after ~30 sec, but with a manual exit request it is faster...
System.exit(0); // remove this exit(0) invoke, now the test-run shutdown is not nice
// see output without the above manual exit(0);
//[WARNING] thread Thread[logback-1,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] was interrupted but is still alive after waiting at least 14999msecs
//[WARNING] thread Thread[logback-1,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-1,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-2,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-3,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-4,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-5,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-6,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-7,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] thread Thread[FelixResolver-8,5,love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher] will linger despite being asked to die via interruption
//[WARNING] NOTE: 9 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
//[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=love.distributedrebirth.gdxapp4d.boot.desktop.GDXAppDesktopLauncher,maxpri=10]
}
@Override

View file

@ -46,6 +46,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.x4o.xml.io.X4OConnectionException;
@ -132,45 +133,47 @@ public class GDXAppTos4Activator implements BundleActivator {
gdxFont.dispose();
}
private void startError(String msg) {
bootScreen.bootLineError("ERROR: " + msg);
startError = true;
LOG.error(msg);
}
@Override
public void start(final BundleContext context) {
bootScreen.bootLine("Mecca System eXtension superscript Four");
bootScreen.bootLine("tos4: starting...");
bootScreen.bootLine("nx01: starting Temple OS engine");
bootScreen.bootLine("init-cpus: "+Runtime.getRuntime().availableProcessors());
bootScreen.bootLine("free-memory: 0x"+Long.toHexString(Runtime.getRuntime().freeMemory()));
BãßBȍőnBőatWindKnots harbor = Bãß.أَكْبَرײꣻײالله.harborᴮʳᵉᵉᶻᵉ(BãßBȍőnBőatWind.SAILOR_MOON_SKIRT_DUSTER);
bootScreen.bootLine("harbor: solar-winds="+harbor.getSolarWinds().size()+" storm-troopers="+harbor.getStormTroopers());
bootScreen.bootLine("nx01-harbor: solar-winds="+harbor.getSolarWinds().size()+" storm-troopers="+harbor.getStormTroopers());
boolean useLocal = args.contains("use-local");
warpshipHome = new File(WARPSHIP_HOME);
if (!warpshipHome.exists()) {
bootScreen.bootLineError("ERROR: No Warpship home.");
startError = true;
startError("No Warpship home.");
return;
}
hyperdriveHome = new File(warpshipHome, HYPERDRIVE_HOME);
if (!hyperdriveHome.exists()) {
bootScreen.bootLineError("ERROR: No Hyperdrive home.");
startError = true;
startError("No Hyperdrive home.");
return;
}
File warpShip = new File(warpshipHome, Warpᵐᵉ.WARP_SHIP);
bootScreen.bootLine("warp-ship: "+warpShip);
if (!warpShip.exists()) {
bootScreen.bootLineError("ERROR: No warp-ship.xml found.");
startError = true;
startError("No warp-ship.xml found.");
return;
}
try {
warpshipDevice = WaterDeviceDriver.newInstance().createReader().readFile(warpShip);
} catch (Exception e) {
e.printStackTrace();
bootScreen.bootLineError("ERROR: "+e.getMessage());
startError = true;
LOG.error(e.getMessage(), e);
startError(e.getMessage());
return;
}
bootScreen.bootLine("warp-engine: "+warpshipDevice.theShip().getName());
@ -209,17 +212,18 @@ public class GDXAppTos4Activator implements BundleActivator {
try {
result = systemWarpShip.loadWaterOcean(context, registratedSeas, warpshipDevice.theShip().getEngine(), v -> bootScreen.bootLine(v));
} catch (Exception e) {
e.printStackTrace();
bootScreen.bootLineError("ERROR: "+e.getMessage());
startError = true;
if (!GDXAppTos4.INSTANCE.isRunning()) {
return;
}
LOG.error(e.getMessage(), e);
startError(e.getMessage());
return;
}
if (result > 0) {
bootScreen.bootLineError("tos4: FAILURE BOOT ABORTED");
startError = true;
if (result < 0) {
startError("SPACE DOCK FAILURE, ENGINE BOOT ABORTED");
return;
}
bootScreen.bootLine("tos4: chains resolved.");
bootScreen.bootLine("nx01-space: Docked with " + result + " warp oceans");
List<File> fonts = systemWarpShip.searchMagic(context, "application/x-font-ttf-plane0");
File systemFont = fonts.get(0);
@ -241,18 +245,25 @@ public class GDXAppTos4Activator implements BundleActivator {
}
bootScreen.bootLine("gdx-font: "+parameter.characters.length()+" glyphs loaded.");
context.registerService(SystemGdxFont.class.getName(), new SystemGdxFontImpl(gdxFont), new Hashtable<String, String>());
context.registerService(SystemGdxLog.class.getName(), systemGdxLog, new Hashtable<String, String>());
context.registerService(SystemGdxBootArgs.class.getName(), new SystemGdxBootArgsImpl(), new Hashtable<String, String>());
context.registerService(SystemGdxTerminal.class.getName(), systemGdxTerminal, new Hashtable<String, String>());
List<ServiceRegistration<?>> pistons = new ArrayList<>();
pistons.add(context.registerService(SystemGdxFont.class.getName(), new SystemGdxFontImpl(gdxFont), new Hashtable<String, String>()));
pistons.add(context.registerService(SystemGdxLog.class.getName(), systemGdxLog, new Hashtable<String, String>()));
pistons.add(context.registerService(SystemGdxBootArgs.class.getName(), new SystemGdxBootArgsImpl(), new Hashtable<String, String>()));
pistons.add(context.registerService(SystemGdxTerminal.class.getName(), systemGdxTerminal, new Hashtable<String, String>()));
bootScreen.bootLine("nx01-engine: Booted " + pistons.size() + " plasma cambers");
pistons.clear();
bootScreen.bootLine("nx01-bridge: Loading vrGEM4");
try {
Thread.sleep(1234+123);
systemWarpShip.loadBundles(context, registratedSeas);
} catch (BundleException e) {
e.printStackTrace();
} catch (Exception e) {
if (!GDXAppTos4.INSTANCE.isRunning()) {
return;
}
LOG.error(e.getMessage(), e);
startError(e.getMessage());
systemGdxTerminal.selectScreen(GDXAppTos4BootScreen.class);
bootScreen.bootLineError("ERROR: "+e.getMessage());
startError = true;
return;
}
}
@ -369,7 +380,7 @@ public class GDXAppTos4Activator implements BundleActivator {
logger.accept(infoResult);
// if (!infoResult.startsWith("Drive Info")) {
// logger.accept("ERROR: Couldn't get info on: "+waterHome);
// return 1;
// return -1;
// }
} else {
waterHome = new File(override);
@ -379,25 +390,25 @@ public class GDXAppTos4Activator implements BundleActivator {
File waterHash = new File(waterHome, Warpᵐᵉ.WARP_HASH);
if (!waterHash.exists()) {
logger.accept("ERROR: Missing file: "+waterHash);
return 1;
return -1;
}
WaterShotAddict addict = new WaterShotAddict();
try {
if (!addict.validateWarpChainLink(waterHome)) {
logger.accept("ERROR: Invalid hash in: "+waterHash);
return 1;
return -1;
}
} catch (NoSuchAlgorithmException | X4OConnectionException | SAXException | IOException e) {
e.printStackTrace();
logger.accept("ERROR: "+e.getMessage());
return 1;
return -1;
}
File waterSea = new File(waterHome, Warpᵐᵉ.WARP_SEA);
if (!waterSea.exists()) {
logger.accept("ERROR: Missing file: "+waterSea);
return 1;
return -1;
}
WaterOcean ocean = WaterOceanDriver.newInstance().createReader().readFile(waterSea);
logger.accept("water-ocean: "+key+" ("+ocean.theWater().getName()+")");
@ -408,7 +419,7 @@ public class GDXAppTos4Activator implements BundleActivator {
context.registerService(SystemWarpSea.class.getName(), sea, props);
registratedSeas.add(sea);
int result = 0;
int result = 1;
for (WaterSeaChain chain: ocean.theWater().getSeaChains()) {
result += loadWaterOcean(context, registratedSeas, chain.getKey(), logger);
}
@ -478,6 +489,11 @@ public class GDXAppTos4Activator implements BundleActivator {
}
return result;
}
@Override
public boolean isRunning() {
return GDXAppTos4.INSTANCE.isRunning();
}
}
public static class SystemGdxLogImpl implements SystemGdxLog, ApplicationLogger {

View file

@ -43,6 +43,8 @@ import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAu
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public interface SystemWarpShip {
boolean isRunning();
WaterDevice getWarpShip();
int loadWaterOcean(BundleContext context, List<SystemWarpSea> registratedSeas, String key, Consumer<String> logger) throws IOException, InterruptedException, X4OConnectionException, SAXException, BundleException;

View file

@ -66,8 +66,6 @@ import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAu
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public class GDXAppVrGem4Activator implements BundleActivator {
private static final int VIEW_SLEEP_TIME = 1234;
@Override
public void stop(final BundleContext context) {
Gdx.app.postRunnable(new Runnable() {
@ -80,11 +78,6 @@ public class GDXAppVrGem4Activator implements BundleActivator {
@Override
public void start(final BundleContext context) {
try {
Thread.sleep(VIEW_SLEEP_TIME);
} catch (InterruptedException ignored) {
}
ServiceReference<SystemGdxLog> loggerRef = context.getServiceReference(SystemGdxLog.class);
SystemGdxLog logger = context.getService(loggerRef);
@ -120,21 +113,17 @@ public class GDXAppVrGem4Activator implements BundleActivator {
result = systemWarpShip.loadWaterOcean(context, registratedSeas, ocean.getSea(), v -> bootScreen.bootLine(v));
}
} catch (Exception e) {
e.printStackTrace();
bootScreen.bootLine("ERROR: "+e.getMessage());
throw new IllegalStateException(e);
}
if (result < 0) {
bootScreen.bootLine("SPACE DOCK FAILURE, WARP SEA NAVIGATION ABORTED");
return;
}
if (result > 0) {
bootScreen.bootLine("vrGEM4: FAILURE BOOT ABORTED");
return;
}
bootScreen.bootLine("vrGEM4: chains resolved.");
bootScreen.bootLine("vrGEM⁴: Resolved " + result + " chains");
try {
systemWarpShip.loadBundles(context, registratedSeas);
} catch (BundleException e) {
e.printStackTrace();
bootScreen.bootLine("ERROR: "+e.getMessage());
return;
throw new IllegalStateException(e);
}
bootArgs.addBootReadyListener(new SystemGdxBootReadyListener() {
@Override
@ -154,7 +143,7 @@ public class GDXAppVrGem4Activator implements BundleActivator {
unicodeService.init(context, systemWarpShip, (v) -> bootScreen.bootLine(v));
context.registerService(VrGem4Unicode4DService.class.getName(), unicodeService, new Hashtable<String, String>());
startBundles(bootScreen);
bootScreen.bootLine("vrGEM⁴: Loaded virtual space");
}
private GDXAppVrGem4BootScreen createBootScreen(SystemGdxTerminal terminal, SystemGdxFont gdxFont) {
@ -167,10 +156,6 @@ public class GDXAppVrGem4Activator implements BundleActivator {
terminal.selectScreen(GDXAppVrGem4BootScreen.class);
}
});
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
return bootScreen;
}
@ -238,18 +223,6 @@ public class GDXAppVrGem4Activator implements BundleActivator {
terminal.registrateScreen(new ScreenHelp(terminal));
}
});
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
}
private void startBundles(GDXAppVrGem4BootScreen bootScreen) {
try {
Thread.sleep(VIEW_SLEEP_TIME);
} catch (InterruptedException ignored) {
}
bootScreen.bootLine("vrGEM4: Init bundles...");
}
@SuppressWarnings("unchecked")

View file

@ -63,6 +63,9 @@ public class VrGem4Unicode4DServiceImpl implements VrGem4Unicode4DService {
List<File> glyps = warpShip.searchMagic(context, "application/x-font-ttf4d");
try {
for (File glypSet : glyps) {
if (!warpShip.isRunning()) {
return;
}
log.accept("Loading glypSet: " + glypSet.getName());
FontAtlas atlas = FontAtlasDriver.newInstance().createReader().readFile(glypSet);
masterFontAtlas.setStores(atlas.getStores());
@ -75,6 +78,9 @@ public class VrGem4Unicode4DServiceImpl implements VrGem4Unicode4DService {
int dup = 0;
for (FontAtlasStore fontStore:masterFontAtlas.getStores()) {
if (!warpShip.isRunning()) {
return;
}
log.accept("Map unicode: "+fontStore.getName()+" size: "+fontStore.getGlyphs().size());
for (FontAtlasStoreGlyph glyph: fontStore.getGlyphs()) {
int unicode = CodePointᶻᴰ.INSTANCE.searchUnicode(glyph.getTongs());

View file

@ -47,7 +47,7 @@ public class ScreenCredits extends AbstractScrollScreen {
"Bunnies have easter egg children with many colored seed spots",
"...",
" ",
"=== BEGIN KJV PAGE ONE ===",
"=== BEGIN OF KJV PAGE ONE ===",
" ",
"### Genesis 1",
" ",
@ -288,9 +288,11 @@ public class ScreenCredits extends AbstractScrollScreen {
" ",
"5 But unto Cain and to his offering he had not respect. And Cain was very wroth, and his countenance fell.",
" ",
"=== BEGIN KJV PAGE ONE ===",
"=== END OF KJV PAGE ONE ===",
" ",
"Page two requires consent for marriage.",
"Page two requires consent for marriage;",
"- Information kills the heart",
"- Love is before the fall to the fruit",
" "
);