The article Shiny - onStop tells that , A function that will be called after the app has finished running. But this works only locally i guess. Because when I deploy the application on shiny server and then open the application and close it, this function (onstop) does not trigger . Is my understanding correct?
I am writing a csv file inside onstop function. So since it is not triggering , there is no csv file. But when opened internally there is a csv file written
On shinyapps.io for example. Even if the on stop function ran and a csv file was written , it would not show in next session because the per session storage is not permanent. Could it be that?
Do you have evidence that the code runs at all? I would have thought it would fail the if interactive() check, if you arent running from console interactively.
I'm not doubting that it runs locally, I'm doubting that it runs remotely. If you are running on server you.wouldnt have interactive access on server console,...
Why not remove
I dont use shiny server pro so, if that's necessary part of this issue, I can't directly help.
I will edit your title and tags to mention shiny server pro
What exactly do you mean by closing the application? If you are closing the browser-tab, this will only end the session but won't stop the server-function from running.
If you want to run code after the session ends you need to place the onStop function call inside the server function or you may register a session$onSessionEnded callback function. Please see the following example, which shows the difference to a global onStop: