Spaces:
Running
Running
added a script to keep session alive
Browse files
app/app.R
CHANGED
@@ -121,7 +121,7 @@ ui <- shinydashboardPlus::dashboardPage(
|
|
121 |
|
122 |
|
123 |
# ============================================================================
|
124 |
-
# Main
|
125 |
# ============================================================================
|
126 |
|
127 |
body = dashboardBody(
|
@@ -136,6 +136,33 @@ ui <- shinydashboardPlus::dashboardPage(
|
|
136 |
|
137 |
fluidPage(
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
markdown("# **Shiny Numerati**"),
|
140 |
markdown("### Community Dashboard for the Numerai Classic Tournament"),
|
141 |
|
@@ -322,7 +349,10 @@ ui <- shinydashboardPlus::dashboardPage(
|
|
322 |
"),
|
323 |
br(),
|
324 |
markdown("## **Session Info**"),
|
325 |
-
verbatimTextOutput(outputId = "session_info")
|
|
|
|
|
|
|
326 |
)
|
327 |
|
328 |
# ========================================================================
|
@@ -680,6 +710,18 @@ server <- function(input, output) {
|
|
680 |
sessionInfo()
|
681 |
})
|
682 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
}
|
684 |
|
685 |
|
|
|
121 |
|
122 |
|
123 |
# ============================================================================
|
124 |
+
# Main Body
|
125 |
# ============================================================================
|
126 |
|
127 |
body = dashboardBody(
|
|
|
136 |
|
137 |
fluidPage(
|
138 |
|
139 |
+
# ==============================================================
|
140 |
+
# Special script to keep session alive
|
141 |
+
# ==============================================================
|
142 |
+
|
143 |
+
tags$head(
|
144 |
+
HTML(
|
145 |
+
"
|
146 |
+
<script>
|
147 |
+
var socket_timeout_interval
|
148 |
+
var n = 0
|
149 |
+
$(document).on('shiny:connected', function(event) {
|
150 |
+
socket_timeout_interval = setInterval(function(){
|
151 |
+
Shiny.onInputChange('count', n++)
|
152 |
+
}, 5000)
|
153 |
+
});
|
154 |
+
$(document).on('shiny:disconnected', function(event) {
|
155 |
+
clearInterval(socket_timeout_interval)
|
156 |
+
});
|
157 |
+
</script>
|
158 |
+
"
|
159 |
+
)
|
160 |
+
),
|
161 |
+
|
162 |
+
# ==============================================================
|
163 |
+
# First Page
|
164 |
+
# ==============================================================
|
165 |
+
|
166 |
markdown("# **Shiny Numerati**"),
|
167 |
markdown("### Community Dashboard for the Numerai Classic Tournament"),
|
168 |
|
|
|
349 |
"),
|
350 |
br(),
|
351 |
markdown("## **Session Info**"),
|
352 |
+
verbatimTextOutput(outputId = "session_info"),
|
353 |
+
|
354 |
+
br(),
|
355 |
+
textOutput("keepAlive") # trick to keep session alive
|
356 |
)
|
357 |
|
358 |
# ========================================================================
|
|
|
710 |
sessionInfo()
|
711 |
})
|
712 |
|
713 |
+
|
714 |
+
# ============================================================================
|
715 |
+
# Trick to keep session alive
|
716 |
+
# https://tickets.dominodatalab.com/hc/en-us/articles/360015932932-Increasing-the-timeout-for-Shiny-Server
|
717 |
+
# ============================================================================
|
718 |
+
|
719 |
+
output$keepAlive <- renderText({
|
720 |
+
req(input$count)
|
721 |
+
# paste("keep alive ", input$count)
|
722 |
+
" "
|
723 |
+
})
|
724 |
+
|
725 |
}
|
726 |
|
727 |
|