Need help for Plumber API & shiny integration

Dear all,
I am writing this in order to understand how I could solve an infrastructure problem.

I have a shinyapp that allows farmers to sign up and report the boundary of the fields.

Following enrollment and input of fields, the shinyapp send a request to the Plumber API which in the backend proceeds to do the downloading of satellite imagery.

Now I would like to understand if it is possible that the shinyapp makes an API request and the plumber API immediately sends a response 200 to the shinyapp so that the user can continue to use the shinyapp and in the meantime the plumber performs in the backend the very long processing of the satellite image

Thanks in advance

Maybe a picture can help to understand my problem.

I tried using this code but the response only comes after the background process which takes over 10 minutes.

#* @tag Satellite
#* @post /SatelliteImages
function(req, res) {

  future_promise({
    system("RScript yourscript.R &")
  })
  
  res$status <- 200
  res$body <- "Registration received. Processing of satellite images has finished."
  
  return(res)

}

Since you are using a system call, try with wait = FALSE?

?system

wait	
a logical (not NA) indicating whether the R interpreter should wait for the command to finish, or run it asynchronously. This will be ignored (and the interpreter will always wait) if intern = TRUE. When running the command asynchronously, no output will be displayed on the Rgui console in Windows (it will be dropped, instead).
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.