Skip to content

Commit

Permalink
Allow setting default host/ip in R server (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
BSchilperoort authored Nov 20, 2024
1 parent 31222d0 commit a230e91
Showing 1 changed file with 3 additions and 1 deletion.
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 @@ library(reqres)
#'
#' @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 @@ serve <- function(model, port = 50051, host = "127.0.0.1", ignite = TRUE) {
router$add_route(route, "bmi")

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

app <- fiery::Fire$new(host = host, port = port)
app$attach(router)
if (ignite) {
Expand Down

0 comments on commit a230e91

Please sign in to comment.