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

issue-408 - server timeout setting configurable through envs #2550

Merged
merged 1 commit into from
Jun 4, 2023
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
7 changes: 7 additions & 0 deletions main/client/src/mill/main/client/MillEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ static boolean millJvmOptsAlreadyApplied() {
return propAppliedProp != null && propAppliedProp.equals("true");
}

static String millServerTimeout() {
return System.getenv("MILL_SERVER_TIMEOUT_MILLIS");
}

static boolean isWin() {
return System.getProperty("os.name", "").startsWith("Windows");
}
Expand Down Expand Up @@ -95,6 +99,9 @@ static List<String> millLaunchJvmCommand(boolean setJnaNoSys) {
}
}

String serverTimeout = millServerTimeout();
if (serverTimeout != null ) vmOptions.add("-D" + "mill.server_timeout" + "=" + serverTimeout);

// extra opts
File millJvmOptsFile = millJvmOptsFile();
if (millJvmOptsFile.exists()) {
Expand Down
8 changes: 7 additions & 1 deletion runner/src/mill/runner/MillServerMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import mill.api.internal
import mill.main.client.lock.{Lock, Locks}
import mill.api.SystemStreams

import scala.util.Try

@internal
trait MillServerMain[T] {
def stateCache0: T
Expand Down Expand Up @@ -46,11 +48,15 @@ object MillServerMain extends MillServerMain[RunnerState] {
def handle(sig: Signal) = {} // do nothing
}
)

val acceptTimeoutMillis =
Try(System.getProperty("mill.server_timeout").toInt).getOrElse(5 * 60 * 1000) // 5 minutes

new Server(
lockBase = args0(0),
this,
() => System.exit(MillClientMain.ExitServerCodeWhenIdle()),
acceptTimeoutMillis = 5 * 60 * 1000, // 5 minutes
acceptTimeoutMillis = acceptTimeoutMillis,
Locks.files(args0(0))
).run()
}
Expand Down