Hi all,
I’m pretty new to the jupyter ecosystem, but have enjoyed what I’ve been able to do so far, thanks to everyone who has been working on this!
I was hoping to use jupyter server proxy as a direct front end to some shiny apps I have written so that I can share them with some jupyter users (eg directly run the shiny app without using something like shiny server). I know that this is an unusual way to have a web app, but my ideal lifecycle is to have the shiny app quit when the user is not using it.
However, when I have the shiny app close, the proxy layer does not seem to start another instance of my app, instead I get a page that says [Errno 111] Connection refused
.
Is there a way that I could indicate to the proxy that the app has closed and it needs to start it from scratch?
I’ve also noticed that sometimes old processes stick around after shutting down the user’s jupyter hub, which seems like it would be a problem if the app didn’t automatically close.
I’m having trouble thinking of a way to share a fully reproducible example, but here’s a shiny app that closes when it’s disconnected from:
test.r
port <- as.numeric(commandArgs(trailingOnly = TRUE)[1])
n <- 200
library(shiny)
runApp(
port = port,
shinyApp(
ui = bootstrapPage(
numericInput('n', 'Number of obs', n),
plotOutput('plot')
),
server = function(input, output, session) {
session$onSessionEnded(function() {
stopApp()
})
output$plot <- renderPlot({
hist(runif(input$n))
})
}
)
)
This R script is called from the Server Process configuration with a single argument {port}
. I’ve done this with a jupyter_notebook_config.py file with the following:
c.ServerProxy.servers = {
'test': {
'command': ['Rscript', 'test.r', '{port}']
}
}