Davie D
Davie D

Reputation: 43

Running R Shiny through RInno Package

I have this Shiny application that I want to run using the RInno package.

Right now my current problem is that after creating the app and then running compile_iss, I get to the setup of the application. Finally, when the application is launching it gives me the following error:

ERROR: Can't call `runApp()` from within `runApp()`. If your application code contains `runApp()`, please remove it.

My application does not contain runApp() anywhere inside of it.

I have included this code at the end:

 session$onSessionEnded(function() {
    stopApp()
    q("no")
  })

I end my shiny app with:

shinyApp(ui = ui, server = server)

Does anyone know how I can resolve that error?

Added Code:

ui <- fluidPage( 
  titlePanel(""),
                      h5(""),
                      sidebarLayout(
                        sidebarPanel(
                          selectInput("type", "Select Type of Record:",
                                      choices=c('A', 'B', 'C'),
                                      selected="A"),
                          DT::dataTableOutput("responses", width = 300), tags$hr(),
                          textInput("Comment", "Comments:", ""),
                          actionButton("submit", "Submit")),
                        mainPanel(    
                          plotlyOutput("plot")
                        )
                      )
             )


server <- function(input, output, session) {
  mydata <- reactive({
    invalidateLater(30 * 60000,session)
    odbcChannel<- odbcConnect("a", uid, pwd) 
    message <- sqlQuery(odbcChannel, "select a, b,c 
                        from table
                        ")
  #I got rid of all the other stuff, as I figured it was unimportant. Let me know if you need to see more

  })

session$onSessionEnded(function() {
    stopApp()
    q("no")
  })

}

Upvotes: 1

Views: 2120

Answers (1)

Jonathan Hill
Jonathan Hill

Reputation: 1843

RInno is designed to call runApp() during the app's startup sequence before any of the app's code is run. shinyApp(ui = ui, server = server) is trying to start the app a second time.

A good pre-compile_iss check is to run runApp("path to ui.R/server.R") because that is exactly how RInno tries to start the app

If you delete shinyApp(ui = ui, server = server) from your app, it should fix the error, but let me know if you are still having an issue and I would be happy to troubleshoot it with you!

Upvotes: 3

Related Questions