Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes for prompt logger #4075

Merged
merged 8 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions main/util/src/mill/util/PromptLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,28 @@ private[mill] class PromptLogger(
if (enableTicker) refreshPrompt()

val promptUpdaterThread = new Thread(
() =>
() => {
var lastUpdate = System.currentTimeMillis()
while (!runningState.stopped) {
val promptUpdateInterval =
if (termDimensions._1.isDefined) promptUpdateIntervalMillis
else nonInteractivePromptUpdateIntervalMillis

try Thread.sleep(promptUpdateInterval)
try Thread.sleep(promptUpdateIntervalMillis)
catch {
case e: InterruptedException => /*do nothing*/
}

readTerminalDims(terminfoPath).foreach(termDimensions = _)

synchronized {
if (!runningState.paused && !runningState.stopped) refreshPrompt()
val now = System.currentTimeMillis()
if (
termDimensions._1.nonEmpty ||
(now - lastUpdate > nonInteractivePromptUpdateIntervalMillis)
) {
lastUpdate = now
synchronized {
if (!runningState.paused && !runningState.stopped) refreshPrompt()
}
}
},
}
},
"prompt-logger-updater-thread"
)

Expand Down
5 changes: 1 addition & 4 deletions runner/client/src/mill/runner/client/MillClientMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import mill.main.client.OutFiles;
import mill.main.client.ServerCouldNotBeStarted;
import mill.main.client.ServerLauncher;
import mill.main.client.Util;
import mill.main.client.*;
import mill.main.client.lock.Locks;

/**
Expand Down
25 changes: 16 additions & 9 deletions runner/client/src/mill/runner/client/MillProcessLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ static int launchMillNoServer(String[] args) throws Exception {
boolean interrupted = false;

try {
Process p = configureRunMillProcess(builder, processDir);
MillProcessLauncher.runTermInfoThread(processDir);
Process p = configureRunMillProcess(builder, processDir);
return p.waitFor();

} catch (InterruptedException e) {
Expand Down Expand Up @@ -230,18 +230,25 @@ static void writeTerminalDims(boolean tputExists, Path serverDir) throws Excepti
Files.write(serverDir.resolve(ServerFiles.terminfo), str.getBytes());
}

public static boolean checkTputExists() {
try {
getTerminalDim("cols", false);
getTerminalDim("lines", false);
return true;
} catch (Exception e) {
return false;
}
}

public static void runTermInfoThread(Path serverDir) throws Exception {
Path sandbox = serverDir.resolve(ServerFiles.sandbox);
Files.createDirectories(sandbox);
boolean tputExists = checkTputExists();

writeTerminalDims(tputExists, serverDir);
Thread termInfoPropagatorThread = new Thread(
() -> {
try {
boolean tputExists;
try {
getTerminalDim("cols", false);
getTerminalDim("lines", false);
tputExists = true;
} catch (Exception e) {
tputExists = false;
}
while (true) {
writeTerminalDims(tputExists, serverDir);
Thread.sleep(100);
Expand Down
Loading