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 WebServer.scala #266

Merged
merged 2 commits into from
Dec 16, 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
4 changes: 1 addition & 3 deletions src/main/scala/esmeta/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ val LINE_SEP = System.getProperty("line.separator")
val VERSION = "0.5.0"

/** base project directory root */
val BASE_DIR =
val path = System.getenv("ESMETA_HOME")
if (path == null) throw NoEnvVarError else path
val BASE_DIR = sys.env.getOrElse("ESMETA_HOME", throw NoEnvVarError)

/** log directory */
val LOG_DIR = s"$BASE_DIR/logs"
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/esmeta/web/WebServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ class WebServer(cfg: CFG, port: Int) {
),
)
}
val bindingFuture = Http().newServerAt(ESMETA_HOST, port).bind(rootRoute)

val bindingFuture = Http().newServerAt("localhost", port).bind(rootRoute)

println(s"Server now online at port $port.\nPress RETURN to stop...")
println(s"Server now online at http://$ESMETA_HOST:$port")
println("Press RETURN to stop...")
StdIn.readLine() // let it run until user presses return
bindingFuture
.flatMap(_.unbind()) // trigger unbinding from the port
Expand Down
3 changes: 3 additions & 0 deletions src/main/scala/esmeta/web/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ def initDebugger(cfg: CFG, sourceText: String): Unit =
val cachedAst = cfg.scriptParser.from(sourceText)
_debugger = Some(Debugger(Initialize(cfg, sourceText, Some(cachedAst))))
private var _debugger: Option[Debugger] = None

/** web server host */
val ESMETA_HOST = sys.env.getOrElse("ESMETA_HOST", "localhost")
Loading