Close proxy from running container?


Does anyone knows the way how to close/stop proxy and close container itself from running container (running Shiny app)?

What is an example of get query to ShinyProxy?

One way to do it could be to use the stopApp() function within the app that would stop the app, and then the container will be removed after the heartbeat timeout is reached.


Thanks! But is it possible to send get or post a query to ContainerProxy API. I can’t find any example in documentation. I can send proxy ID into container through env specification. How I can use this PROXY_ID in get/post query?

  - id: My_app
    display-name: My App
    description: Awesome App
    container-cmd: ["R", "-e shiny::runApp('/home/app/app',port=3838,host='')"]
    container-image: myimage
    container-volumes: ["/srv/app/data:/home/app/app"]
      PROXY_ID: "#{}"

To stop the container you need to make a DELETE request, for which you need to know the container id. You get it the response after you started the app with a POST request.
E.g. from R it would look something like:

stop_for_status(res <- POST("http://[SERVER_URL]/api/proxy/my_app", encode = "json"))
id <- content(res)$id
# ...
stop_for_status(res2 <- DELETE(paste0("http://[SERVER_URL]/api/proxy/", id)))

Here my_app is your PROXY_ID.

1 Like