How to push a change to ui.R or server.R for a already live shiny app?

2,890 views
Skip to first unread message

Jeffrey Wong

unread,
Jul 14, 2015, 9:21:20 PM7/14/15
to shiny-...@googlegroups.com
Hi everyone,

I am running a server with a number of shiny apps on it. If I want to update server.R on one of them, what is the best way to push that update so the end user can see it right away? I imagined that the user can just refresh their tab and get a new session, thereby seeing results from the new code, but I don't think that happens. Does anyone know under what conditions will the user get a new session? If I do a shiny-server restart that seems to give the user a new session, but there are many other apps on this server and I don't want to do a shiny-server restart every time someone edits server.R.

Thanks for advice

Jar Jarder

unread,
Jul 15, 2015, 12:37:06 AM7/15/15
to shiny-...@googlegroups.com
Hello,

We simply overwrite ui.R and server.R when we have updates. No need to restart the server. The user just refreshes the page, and the changes appear immediately.

If you need to reload packages, you would need to "trick" the shiny server by creating a dummy file on the app's directory.


Good luck. :)
Jar

Dean Attali

unread,
Jul 15, 2015, 1:38:13 AM7/15/15
to shiny-...@googlegroups.com
Just to add to Jar's response: if you modify server or ui then you don't need to do anything else - the app will update right away. But if your app has other files (helper R scripts, javascript, css, images, any other files) then you need to update the timestamp on the "restart.txt" file

Jeffrey Wong

unread,
Jul 15, 2015, 12:04:22 PM7/15/15
to shiny-...@googlegroups.com
Thanks, so if I write in server.R

shinyServer(input, output, session) {
  source("myHelperFunctions.R")
  <a new line here>
}

then
a) push a change to server.R - will all of myHelperFunctions get re-sourced since server.R was touched?

b) What if server.R was not touched at all, but myHelperFunctions.R was. If I push that to the shiny server it will not pick up the changes in myHelperFunctions unless I include restart.txt?

Jeffrey Wong

unread,
Jul 15, 2015, 12:07:28 PM7/15/15
to shiny-...@googlegroups.com
Another use case I want to verify is

shinyServer(input, output, session) {
  x = read.csv("mydata.csv")
}

If only mydata.csv was changed, and not server.R, I should update the restart.txt file? And if Both files were updated I don't need to do anything since shinyServer(input, output, session) will get rerun anyway?

Dean Attali

unread,
Jul 15, 2015, 1:57:08 PM7/15/15
to Jeffrey Wong, shiny-...@googlegroups.com

I would just make a small simple dummy Shiny app and test those cases to learn about all the cases and see it for yourself :)

--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/yTu0clq1pXI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/625afe98-f27a-471f-b28b-0df3d72eb2c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joe Cheng

unread,
Jul 15, 2015, 4:36:20 PM7/15/15
to Dean Attali, Jeffrey Wong, shiny-...@googlegroups.com
a) yes
b) "touch restart.txt" is required
c) yes, the data should be updated just by virtue of read.csv being called every time a new session connects

You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/CA%2Bj8Z%2BmEoMt83df370XzhURvX46UoVZb5Vn7%3DOGaXuQomayhCg%40mail.gmail.com.

Jeffrey Wong

unread,
Jul 23, 2015, 5:09:20 AM7/23/15
to Shiny - Web Framework for R
Thanks, I understand touch restart a lot more now. It seems that doing this will not interrupt an existing connection, so an end user may still be looking at old assets. What is the best way to refresh that connection? Is it to refresh the tab, or is it necessary to clear the browser's cache?
Reply all
Reply to author
Forward
0 new messages