我已经在Mac和Ubuntu中尝试了很多选项。我阅读了Rserve文档
http://rforge.net/Rserve/doc.html对于Rserve和RSclient包:
http://cran.r-project.org/web/packages/RSclient/RSclient.pdf
http://cran.r-project.org/web/packages/Rserve/Rserve.pdf
我不知道在Rserve中打开/关闭连接以及“优雅地”关闭Rserve的正确工作流程是什么。
例如,在Ubuntu中,我使用./config --enable-R-shlib (遵循Rserve文档)从源代码安装了R,并在/etc/Rserve.conf中添加了'control enable‘行。
在Ubuntu终端中:
library(Rserve)
library(RSclient)
Rserve()
c<-RS.connect()
c ## this is an Rserve QAP1 connection
## Trying to shutdown the server
RSshutdown(c)
Error in writeBin(as.integer....): invalid connection
RS.server.shutdown(c)
Error in RS.server.shutdown(c): command failed with satus code 0x4e: no control line present (control commands disabled or server shutdown)但是,我可以关闭连接:
RS.close(c)
>NULL
c ## Closed Rserve connection关闭连接后,我也尝试了这些选项(也尝试了参数'c',即使连接已关闭):
RS.server.shutdown()
RSshutdown()所以,我的问题是:
1-如何优雅地关闭Rserve?
2-可以在没有RSclient的情况下使用Rserve吗?
我还看了
How to Shutdown Rserve(), running in DEBUG
但是这个问题涉及到调试模式,也没有得到解决。(我没有足够的名气来评论/询问关机是否在非调试模式下工作)。
还查看了以下内容:
how to connect to Rserve with an R client
非常感谢!
发布于 2014-10-15 04:18:07
加载Rserve和RSclient包,然后连接到实例。
> library(Rserve)
> library(RSclient)
> Rserve(port = 6311, debug = FALSE)
> Rserve(port = 6312, debug = TRUE)
Starting Rserve...
"C:\..\Rserve.exe" --RS-port 6311
Starting Rserve...
"C:\..\Rserve_d.exe" --RS-port 6312
> rsc <- RSconnect(port = 6311)
> rscd <- RSconnect(port = 6312)看起来他们在跑..。
> system('tasklist /FI "IMAGENAME eq Rserve.exe"')
> system('tasklist /FI "IMAGENAME eq Rserve_d.exe"')
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
Rserve.exe 8600 Console 1 39,312 K
Rserve_d.exe 12652 Console 1 39,324 K让我们把它们关掉。
> RSshutdown(rsc)
> RSshutdown(rscd)他们都走了..。
> system('tasklist /FI "IMAGENAME eq Rserve.exe"')
> system('tasklist /FI "IMAGENAME eq Rserve_d.exe"')
INFO: No tasks are running which match the specified criteria.通过使用args和/或配置脚本启动Rserve,可以在不使用RSclient的情况下使用它。然后,您可以从其他程序(如Tableau)或使用您自己的代码连接到它。RSclient提供了一种将命令/数据从R的实例传递到Rserve的方法。
希望这能有所帮助:)
发布于 2016-02-11 19:32:43
在Windows系统上,如果您想关闭一个RServe实例,可以使用R中的system函数来关闭它。例如在R中
library(Rserve)
Rserve() # run without any arguments or ports specified
system('tasklist /FI "IMAGENAME eq Rserve.exe"') # run this to see RServe instances and their PIDs
system('TASKKILL /PID {yourPID} /F') # run this to kill off the RServe instance with your selected PID如果您已正确关闭具有该PID的RServe实例,则会出现以下消息:
成功: PID为xxxx的进程已终止。
您可以通过输入以下命令检查RServe实例是否已关闭
system('tasklist /FI "IMAGENAME eq Rserve.exe"')
再来一次。如果没有任何RServe实例正在运行,您将收到以下消息
信息:没有与指定条件匹配的任务正在运行。
有关此主题的更多帮助和信息,请参阅this related question。
请注意,在前面的答案中提到的“RSClient”方法比这个方法更整洁和容易,但我还是向那些启动RServe而不知道如何停止它的人提出了它。
发布于 2018-07-21 06:11:27
如果你不能在R中关闭它,运行下面的代码在终端中杀死它。这些代码可以在Mac上运行。
$ ps ax | grep Rserve # get active Rserve sessions您将看到如下所示的输出。29155是活动的Rserve会话的作业id。
29155 /Users/userid/Library/R/3.5/library/Rserve/libs/Rserve
38562 0:00.00 grep Rserve然后运行
$ kill 29155 https://stackoverflow.com/questions/26225066
复制相似问题