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

Update scala from 2.13.12 to 2.13.13 #930

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions packages/client/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,47 @@ export function delay(milliseconds: number): Promise<void> {
})
}

/**
* Find the first available port in a range, or null if no ports are available
* @param startPort start of the port range
* @param endPort end of the port range
* @returns first available port in the range, or null if no ports are available
*/
export async function findFirstAvailablePort(
startPort: number,
endPort: number
): Promise<number | null> {
const log = getLogger()
return new Promise((resolve) => {
let currentPort = startPort

const tryNextPort = () => {
if (currentPort > endPort) {
resolve(null) // No ports available in the range
return
}

const server = createServer()
server.listen(currentPort, '0.0.0.0', () => {
server.close((err) => {
if (err) {
log.error(`Error closing server on port ${currentPort}: ${err}`)
}
resolve(currentPort) // Found an available port
})
})

server.on('error', (err) => {
log.error(`Error when trying to listen on port ${currentPort}: ${err}`)
++currentPort
tryNextPort() // Try the next port
})
}

tryNextPort()
})
}

/**
* Wait for file to exist
* @param filePath path to file to wait for
Expand Down
2 changes: 1 addition & 1 deletion server/scala/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ lazy val enumeratumVersion = "1.7.2"
lazy val commonSettings =
Seq(
organization := "com.ctc",
scalaVersion := "2.13.12",
scalaVersion := "2.13.14",
version := omegaEditVersion,
organizationName := "Concurrent Technologies Corporation",
maintainer := "oss@ctc.com",
Expand Down
2 changes: 1 addition & 1 deletion server/scala/project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.1")
addSbtPlugin("org.apache.pekko" % "pekko-grpc-sbt-plugin" % "1.0.0")
addSbtPlugin("org.musigma" % "sbt-rat" % "0.7.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0")
addSbtPlugin("com.sksamuel.scapegoat" %% "sbt-scapegoat" % "1.2.2")
Loading