Fresh new session for rstudio-server - r

I am running rstudio-server on a virtualised (vmware-player) ubuntu machine, and processing lots of data into the ram. I find that after some inactivity that the session suspends the data. The problem is that it takes a VERY long time to resume this session and it is making both the host machine and virtual machine lag very badly.
I just want to kill the session and start a new fresh session of rstudio-server, but so far the only way I have found which does this is to reisub my ubuntu machine. Does anyone know a better solution?
As a side note, I think entering session-timeout-minutes=0 in /etc/rstudio/rsession.conf as per here should fix the problem of the session suspending.

I found this page, which deals with resetting the rstudio-desktop version. In my home directory, I found the folder ~/.rstudio. I renamed/deleted this folder and this loads a new rstudio-server instance.
In fact, there is a folder called suspended session in the ~/.rstudio folder, which I suspect is the thing where suspended data is stored, so maybe deleting this folder is sufficient?

If there is a directory inside ~/.rstudio/sessions/active/, deleting it (in the way like rm -rf ~/.rstudio/sessions/active/session-*) might be sufficient to solve the problem.

Your question is a while back but after running into this problem a zilion times i found a way to reset the Rstudio Shiny Server session without the need for admin rights on Rstudio Shiny Server:
put temporarily as first line in server.r :
quit("yes") # FORCE CLOSE OF SESSION server
go to the site and it will crash (the session closes straight away)
delete or comment out:
# quit("yes") # FORCE CLOSE OF SESSION server
go to the site and you will have the shiny app with a new session =^)
Works for me and saves a lot of time searching through all kind of system folders or the need to enter a part of the system that you are not allowed to go or needing admin rights on Rstudio Shiny Server.
I hope this helps.

I have tried the above solutions which didn't work for me. I tried to kill the rsession which is causing the problem. just run this command to find out pid of user session.
ps -u userid
Find out the pid that is causing the rsession to stall. Kill that process and you're good to go.

Note that with newer versions of Rstudio, this folder is now under
~/.local/share/rstudio/sessions/
while in some older versions, it can also be seen in ~/.rstudio-desktop, see documentation page

A quick solution would be to rename ~/.rstudio and reopen the webpage using rstudio url.

Related

RStudio Server immediately freezes and crashes browser after starting

I have an Rstudio Server installation on a Linux Azure VM that seems frozen and also crashes any browser I try to login with.
I have restarted the VM and separately restarted RStudio Server (similarly to the solution in this post) a number of times, but it does not change the behavior. I didn't think I had it set to reload an environment or operation upon restart, but perhaps I accidentally did. The last thing I was doing with the server was a large sparse matrix operation that turned out to be too much for it.
Since the problem occurs immediately after the app loads, I'm not sure how to reset its state. I tried following these instructions but it didn't work:
I renamed ~/.rstudio to ~/.rstudio.backup while RStudio Server was stopped and it was recreated on the next start, but it still resumed in the same state. I saw mentions of ~/.local/share/rstudio/ and ~/.config/rstudio in the support docs, but they do not seem to exist in this Azure Ubuntu installation.
I also moved and renamed the folder of the last used R project, but it had no effect. There is a .config/R/ folder but it only contains a rsconnect folder and 2 empty subfolders.
I finally got it. After shutting down and restarting RStudio Server it was necessary to run this command immediately after RStudio Server loaded:
sudo rstudio-server suspend-all

R studio not responding

My RStudio is opening multiple processes(opening R Studio in different windows) when I open just one. I am not able to open any project. It becomes unresponsive. I tried using in compatibility mode, running as admin and also uninstalled. But still,(here's the image) the same problem persists. Can someone please help me?
Before you reinstall everything, which may take a lot of time, it is worth removing application data, which is a cache R keeps of last sessions etc. It involves settings such as information from last session, etc which RStudio tries to reopen every time you open it.
For app data, look under your user folder which must be somewhere like
c:\Users\<your_user_here\AppData\Local
c:\Users\<your_user_here\AppData\Local\LocalLow
c:\Users\<your_user_here\AppData\Roaming
Delete every subfolder called R, RStudio-Desktop or RStudio under these folders. Don't worry, you won't lose your source program files and projects. It may help you recover everything without having to start over from scratch.

Shiny application started with Rscript and CMD is unavailable after time

I have a small .bat script that runs an app using "Rscript" when the user logs in. After some time, the application / server becomes unavailable. There is no error, the page only loads for forever. When the app is started manually through RStudio there is no problem with the access to the app even after days of running. Any idea what causes this and how to solve it?
I think this will help you. It is supposed to be the correct way to launch a R Shiny app.
R -e "shiny::runApp('~/shinyapp')"
(1st result on Google ... Pardon my tone, but have you searched for this before to ask Stackoverflow how to deal with this problem?)

RStudio Server on Microsoft Azure instance

I am currently running R on a Microsoft Azure instance (Ubuntu virtual machine) using RStudio as my IDE, to which I connect simply through my browser. I am trying to run some commands that take quite some time to complete from within RStudio and figured that I could simply close my tab with RStudio open and the process would keep running. However, when I try to reconnect to see how the process is doing, the page keeps loading but I am unable to see RStudio.
I have a few questions regarding running RStudio on a server:
First, am I correct in thinking that I can close my tab and keep the process running?
Second, is it normal behaviour that I am unable to connect to the server while the process is running?
Third, am I going about this the correct way or are there better ways?
Yes, you can close your tab and keep it running.
RStudio Server waits on updates from the R process to update the UI. This means that if you have a long-running computation, your tab may not fully reload until it's finished. You may also have seen this in the middle of a session: when R is busy, you can have problems saving scripts that are open in the editor pane.
Logging out in the middle of a computation should be safe, but be aware that RStudio will save your workspace and shut R down after a period of inactivity. It then reloads everything when you log back in. But this only extends to objects in memory; if you have any files saved in your temp directory, they'll have disappeared when you come back. They're probably still on the disk, but since your new R session has a new temp directory, you'll have to do a manual search for them.

How to recover RStudio session after crash?

I would like to know how to restore my previous RStudio session after RStudio and the R session crashed.
Background:
I find that my R session crashes very often, at random times for random reasons. I am fine with that I guess.
Most of the time RStudio restarts the R session and I can continue.
But sometimes it just freezes at which time I noticed power cycling the entire machine allows RStudio to recover and even reload my old session.
Stupid me, I don't think power cycling is a good idea so I manually killed the R session, but then RStudio responded but was not really working so I restarted it and it came back with an empty work-space.
I have been backing up with Session->Save Workspace As, but it seems to do nothing as recovering leaves me with the blank empty environment.
I am looking to restore the RStudio display, including the command history , which for a novice like me is precious, and my list of open scripts, some of which were unsaved at the time of the crash.
I am assuming since RStudio can recover itself, there is a file somewhere I can use to recover it.
And if there is no way to recover, how can I completely save my workspace so this cannot happen again?
Also, is there a proper way to recover from an RStudio freeze without a hard reset?
It has been a while since I asked this question. I was never able to fully recover, but I switched to Rprojects which is the recommended way to use Rstudio.
Rprojects are stored in a folder and they remember all files and data from that project in that folder.
This did not help me with my initial problem, but projects prevent it from happening again. The hard part is moving a work-space to a project if it was not in a project to start.
Hi the first step of this article helped me entirely.
https://datacornering.com/how-to-restore-closed-unsaved-script-in-rstudio/
Basically, if on windows, go to C:\Users\xx\AppData\Local\RStudio\sources\s-xx and find a file with "-contents" at the end. This is your unsaved file.

Resources