How do you control the lifetime of a Rook server? - r

I am new to R and to Rook. I am able to successfully run Rook in a browser when I run from RTerm or from RStudio. However, when I run from RScript I get connection refused. My guess is that RScript runs my script and exits the script.
So how would I package up a R Rook application for end users that does not require starting RTerm and manually exiting after the user closes the web pages? Is there a way to handle this using HTTP 1.1 keep alive?

Ahh... It looks like there is an example of doing this. See https://groups.google.com/forum/#!msg/rrook/_da0Xmf8ZWY/SF0k1OvYzGoJ and open the conversation from Sven and download simplerookapp.zip. I have not yet had a chance to verify it, but it does look promising.

Related

Running R code via Rstudio on a remote server not by browser

Is there a way to use a local Rstudio installation on my machine which is actually running the code on a remote server where I can run distributed jobs via SLURM?
Can it be compatible with version control and dockers?
The remoter package does what you are wanting to do very well. You start R on the remote server and run remoter :: server(showmsg=TRUE). Then in you local RStudio you run
remoter :: client (). Works fairly flawlessly.
My main issue is that when you run help it comes from the remote session in the console rather than the help window.
https://cran.r-project.org/web/packages/remoter/vignettes/remoter.pdf

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?)

Workflow for using command line R?

I am used to using R in RStudio. For a new project, I have to use R on the command line, because the data storage and analysis are only allowed to be on a specific server that I connect to using ssh. This server doesn't have rstudio-server to support remote RStudio sessions.
The project involves an extremely large dataset, and some pre-written code to load/format the data that I have been told to run using "source()" before I do anything else. This takes several minutes to run and load the data each time.
What would a good workflow be for something like this? Editing my code in a .r file, saving, then running it would require taking several minutes to load the data each time. But just running R in an interactive session would make it hard to keep track of what I am doing and repeat things if necessary.
Is there some command-line equivalent to RStudio where you can have an interactive session but be editing/saving a file of your code as you go?
Sounds like JuPyteR might be your friend here.
The R kernel works great.
You can use it on a remote server either with exposing an open port (and setting up JuPyteR login credentials)
Or via port forwarding over SSH.
It is a lot like an interactive reply, except it holds state.
And you can go back and rerun cells.
(Of course state can be dangerous for reproduceability)
For RStudio you can launch console and ssh to your remote servers even if your servers don't use expensive RStudio for servers platform. You can then execute all commands from R Studio directly into the ssh with the default shortcut key. This might allow to continue using R studio, track what you're doing in the R script, execute interactively.

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.

Fresh new session for rstudio-server

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.

Resources