2015-11-21 64 views
1

我在Linux服務器上部署了一個閃亮的應用程序。如果一分鐘內沒有任何活動,我希望應用程序超時。根據我讀到的內容,我將app_idle_timeout添加到shiny-server.conf文件,但我注意到它不起作用。有人可以請建議如何確保一分鐘後會話超時嗎?注意:我沒有閃亮的服務器PRO。閃亮的服務器會話超時不起作用

下面是我的shiny-server.conf的樣子。

Instruct Shiny Server to run applications as the user "shiny" 
run_as shiny; 

# Define a server that listens on port 3838 
server { 
    listen 3838; 

    # Define a location at the base URL 
    location/{ 

    # Host the directory of Shiny Apps stored in this directory 
    site_dir /srv/shiny-server; 

    # Log all Shiny output to files in this directory 
    log_dir /var/log/shiny-server; 
    app_idle_timeout 60; 

    # When a user visits the base URL rather than a particular application, 
    # an index of the applications available in this directory will be shown. 
    directory_index on; 

    } 
} 
~     

回答

1

會話超時功能在開源閃亮服務器上不可用。它只是作爲專業版的一部分。

+0

我已經添加了示例繞過 –

2

您可以在shiny應用程序中配置idle時間,就像使用一些JS一樣,此應用程序將在5秒後超時。

library(shiny) 
library(leaflet) 

inactivity <- "function idleTimer() { 
    var t = setTimeout(logout, 5000); 
    window.onmousemove = resetTimer; // catches mouse movements 
    window.onmousedown = resetTimer; // catches mouse movements 
    window.onclick = resetTimer;  // catches mouse clicks 
    window.onscroll = resetTimer; // catches scrolling 
    window.onkeypress = resetTimer; //catches keyboard actions 

    function logout() { 
    window.close(); //close the window 
    } 

    function resetTimer() { 
    clearTimeout(t); 
    t = setTimeout(logout, 5000); // time is in milliseconds (1000 is 1 second) 
    } 
} 
idleTimer();" 


ui <- fluidPage(
    tags$script(inactivity),  
    leafletOutput("mymap") 

) 

server <- shinyServer(function(input,output,session){ 

    points <- eventReactive(input$recalc, { 
    cbind(rnorm(40) * 2 + 13, rnorm(40) + 48) 
    }, ignoreNULL = FALSE) 

    output$mymap <- renderLeaflet({ 
    leaflet() %>% 
     addProviderTiles(providers$Stamen.TonerLite,options = providerTileOptions(noWrap = TRUE)) %>% 
     addMarkers(data = points()) 
    }) 

}) 
runApp(list(ui = ui, server = server))