7

In my Rscript (run.R):

library(plumber)
r <- plumb("script.R")
r$run(host="127.0.0.1",port=8000)

If I run the above code using RStudio or R console it works fine and gives me access after following output:

Starting server to listen on port 8000 Running the swagger UI at http://127.0.0.1:8000/swagger/

but when I try to run the same code as a .R file using Rscript, R CMD BATCH,R < run.R, pm2 it gets stuck at;

Starting server to listen on port 8000

and on accessing address I get 404: Resource Not Found Error. Also, note that I want to run this on windows therefore didn't try littler. Any idea, what I am doing wrong here. Thanks!

Yusra Shahid
  • 104
  • 9

1 Answers1

7

run takes a swagger argument that defaults to interactive(). i.e. it only enables swagger if you're running interactively.

You can hardcode this to TRUE if you want Swagger to be enabled on your router even when run programmatically.

r$run(host="127.0.0.1", port=8000, swagger=TRUE)
Jeff Allen
  • 17,277
  • 8
  • 49
  • 70