-
Notifications
You must be signed in to change notification settings - Fork 256
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
Add the availability to plumber in order to start it without blocking the r process #451
Comments
@andraspetrik |
This can be accomplished using RStudio background jobs. See example here: https://github.com/sol-eng/background-jobs/tree/master/plumber-job |
I'm want to write some api tests. So, whenever I run the plumber server, the tests hang because it blocks. Is there a way to write tests on plumber-api's ? (If plumber wouldn't be blocking after startup, this would be rather straight forward) |
What is done internally is call the Plumber R6 $ methods directly instead of running the server. plumber/tests/testthat/test-plumber.R Line 187 in 43067ff
You could do something like that. pr <- plumb("plumber.R")
req <- #create a mock req object or save one from a sample and load it.
pr$call(req) It will mostly do the same thing without the running server part like. |
Hoping @blairj09 or @schloerke may have a solution. So the "call" method is not the right ("running") way to do this and although I had successfully gone the https://github.com/ATFutures/geoplumber/blob/17f07ada3fe47ae81319c49d1299a1c96305aff6/R/plumb.R#L69
Will update this closed ticket if I find the cause/fix myself. Thanks |
The visual documentation is now enabled in interactive mode. You are probably running inside RStudio and your plumber option You could disable the callback or disable the visual documentation. That would be my hypothesis as rs_plumberviewer is what RStudio use to open plumber visual documentation. |
f <- function(s, p, h) s$run(port = p, host = h) replace with below to set docs callback to null (visual documentation will still be available) f <- function(s, p, h) { s$setDocsCallback(); s$run(port = p, host = h)} or to remove visual documentation entirely f <- function(s, p, h) { s$setDocs(FALSE); s$run(port = p, host = h)} |
Thank you very much @meztez! Can I help documenting this somewhere better for everyone else? Apologies for the single letter codes will revamp it now that I think |
This is more of an RStudio problem though... don't know where you would document that. See third breaking change : https://www.rplumber.io/news/index.html#breaking-changes |
Maybe I need to understand the actual issue rather than jumping to contribute. Thanks again @meztez |
Add the avaiability to start plumber without blocking like httpuv::startServer()
The text was updated successfully, but these errors were encountered: