How to close Rserve from the command line
Asked Answered
C

1

6

this question relates to close connection and perhaps also to this close Rserve. However, in the later case there are connections open and in the first case the answer does not specify how to "kill" the server.

It is important to say that I am new to Rserve, and I have used it for the 1st time today for some mild R-python interaction. I started Rserve from the command line as:

% R CMD RServe

I though I had closed the connection after the session, but when I now try to re-start Rserve again with a new configuration I get the error:

% ##> SOCK_ERROR: bind error #48(address already in use)

which is pretty clear. Moreover ps ax | grep Rserve returns:

% ps ax | grep Rserve
18177   ??  Ss     0:00.33 /Library/Frameworks/R.framework/Resources/bin/Rserve
18634 s006  U+     0:00.00 grep Rserve 

which I understand that indeed means that the server is running. I have tried a few things:

% R CMD RSclose
 /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: RSclose: not found

% R CMD RSshutdown
 /Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: RSshutdown: not found

and finally

% R CMD shutdown
 shutdown: NOT super-user

I am wondering, should I then run:

% sudo R CMD shutdown

(I would like to make sure before running that command, in case I screw something)

Anyway, the question would be very simple. How can I close server to re-run it.

Thanks in advance for your time!

Cottrell answered 5/5, 2015 at 12:29 Comment(0)
P
8

You are confused:

 R CMD something

will always go to R. And R no longer knows Rserve is running even though you may have started it via R CMD Rserve: these are now distinct processes.

What you should do is

 kill 18177       # or possibly  kill -9 18177

and there are wrappers to kill which first grep for the name and find the PID for you:

 killall Rserve   # or possibly  killall -9 Rserve

The -9 sends a higher-order SIGKILL (ie 'really go and die now') intensity than the default of -15 for SIGTERM) (ie 'please stop now').

Place answered 5/5, 2015 at 12:40 Comment(3)
Many thanks Dirk for solving my confusion. I rarely use R CMD, so I had many fronts there to be confused by. Thanks again.Cottrell
My pleasure. I am a big fan of Rserve.Place
I just started using it and to be honest I still do not fully understand its "power" (I know that is basically a server, but surely there is more to it). I have been using pyRserve all day. Still do not understand well how R and python communicate through Rserve, but is just a matter of time. I feel this is going to be very useful!Cottrell

© 2022 - 2024 — McMap. All rights reserved.