本文介绍了如何正常关闭Rserve?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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从源代码安装R(遵循Rserve文档),并且还在/etc/Rserve.conf中添加了"control enable"行./p>

在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吗?

我也看过

如何关闭在调试中运行的Rserve()

,但该问题涉及调试模式,并且也未解决. (我没有足够的声誉来评论/询问关机是否在非调试模式下工作.)

还看着:

如何使用R客户端连接到Rserve

非常感谢!

解决方案

加载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传递命令/数据的方法.

希望这会有所帮助:)

I have tried many options both in Mac and in Ubuntu.I read the Rserve documentation

http://rforge.net/Rserve/doc.html

and that for the Rserve and RSclient packages:

http://cran.r-project.org/web/packages/RSclient/RSclient.pdf

http://cran.r-project.org/web/packages/Rserve/Rserve.pdf

I cannot figure out what is the correct workflow for opening/closing a connection within Rserve and for shutting down Rserve 'gracefully'.

For example, in Ubuntu, I installed R from source with the ./config --enable-R-shlib (following the Rserve documentation) and also added the 'control enable' line in /etc/Rserve.conf.

In an Ubuntu terminal:

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)

I can, however, CLOSE the connection:

RS.close(c)
>NULL
c ## Closed Rserve connection

After closing the connection, I also tried the options (also tried with argument 'c', even though the connection is closed):

RS.server.shutdown()
RSshutdown()

So, my questions are:

1- How can I close Rserve gracefully?

2- Can Rserve be used without RSclient?

I also looked at

How to Shutdown Rserve(), running in DEBUG

but the question refers to the debug mode and is also unresolved. (I don't have enough reputation to comment/ask whether the shutdown works in the non-debug mode).

Also looked at:

how to connect to Rserve with an R client

Thanks so much!

解决方案

Load Rserve and RSclient packages, then connect to the instances.

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

Looks like they're running...

> 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

Let's shut 'em down.

> RSshutdown(rsc)
> RSshutdown(rscd)

And they're gone...

> 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.

Rserve can be used w/o RSclient by starting it with args and/or a config script. Then you can connect to it from some other program (like Tableau) or with your own code. RSclient provides a way to pass commands/data to Rserve from an instance of R.

Hope this helps :)

这篇关于如何正常关闭Rserve?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 22:54