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

Allow setting default host/ip in R server #39

Merged
merged 1 commit into from
Nov 20, 2024
Merged
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: 3 additions & 1 deletion R/R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @param model The model instance to be served. Must implement the subclass of [AbstractBmi](https://github.com/eWaterCycle/bmi-r/blob/master/R/abstract-bmi.R)
#' @param port The port to serve the model on. Default is 50051 or if BMI_PORT environment variable is set, it will be used.
#' @param host The host to serve the model on. Default is "127.0.0.1".
#' @param host The host to serve the model on. Default is "127.0.0.1". NOTE: in a container 127.0.0.1 won't be accessible to the outside, use the BMI_HOST environment variable to set the host IP to 0.0.0.0.
#' @param ignite Whether to ignite the server immediately and block. Default is TRUE.
#' @return The server application.
#' @export
Expand All @@ -18,6 +18,8 @@
router$add_route(route, "bmi")

port <- as.integer(Sys.getenv("BMI_PORT", port))
host <- Sys.getenv("BMI_HOST", host)

Check warning on line 22 in R/R/server.R

View check run for this annotation

Codecov / codecov/patch

R/R/server.R#L21-L22

Added lines #L21 - L22 were not covered by tests
app <- fiery::Fire$new(host = host, port = port)
app$attach(router)
if (ignite) {
Expand Down