Close proxy from running container?

Hi!

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.

2 Likes

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?

  specs:
  - id: My_app
    display-name: My App
    description: Awesome App
    container-cmd: ["R", "-e shiny::runApp('/home/app/app',port=3838,host='0.0.0.0')"]
    container-image: myimage
    container-volumes: ["/srv/app/data:/home/app/app"]
    container-env:
      PROXY_ID: "#{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