如何启动/停止/刷新OpenCPU到CentOS6?

时间:2022-10-13 21:16:06

I've successfully built and installed OpenCPU and RStudio Server on a CentOS6. Everything is working as expected, and I do get successful GET/POST responses for my local R packages.

我已经成功地在CentOS6上构建并安装了OpenCPU和RStudio服务器。一切都按预期运行,我的本地R包也获得了成功的get /POST响应。

A couple of things that don't seem to work however:

然而,有两件事似乎并不奏效:

  • I can't figure a clean way to start/stop/flush OpenCPU. I'm currently using apachectl restart but I'm not even sure that does reload R packages as expected. I tried Jeroen's bash scripts at /usr/lib/opencpu/scripts but they seem to require quite a bit of tweaking to work on CentOS.
  • 我想不出一个干净的方法来启动/停止/刷新OpenCPU。我目前正在使用apachectl重新启动,但我甚至不确定是否按预期重新加载R包。我在/usr/lib/opencpu/scripts上尝试了Jeroen的bash脚本,但是它们似乎需要对CentOS进行一些调整。
  • (maybe related to above) I am using load() and readRDS() in /etc/opencpu/Renviron file (also tried in /etc/opencpu/Rprofile) to load persistent datasets into the global environment -- but that doesn't seem to work. I don't get any error log, but the objects are not available in subsequent requests.
  • (可能与上面相关)我正在使用load()和readRDS()在/etc/ opencpu/renvironmenton文件(也在/etc/opencpu/Rprofile中尝试过)中加载持久性数据集到全局环境中——但这似乎行不通。我没有得到任何错误日志,但是对象在后续请求中不可用。
  • on Ubuntu OpenCPU seems configured to run under an opencpu user. On CentOS6 it seems to run under root after installation. I'd like to modify that, but not sure how.
  • 在Ubuntu OpenCPU上,似乎配置为在OpenCPU用户下运行。在CentOS6上,它似乎在安装之后在根目录下运行。我想修改一下,但不确定如何修改。

Just wondering if someone has has success configuring OpenCPU on CentOS6.

只是想知道是否有人成功地配置了OpenCPU的CentOS6。

Many thanks, --Mel.

多谢,梅尔。

1 个解决方案

#1


2  

Some answers

一些答案

  • Running sudo apachectl restart will do the restart. There is currently no special init or systemd script for opencpu included with the rpm, but basically all that script does on ubuntu is restart apache and print some messages to the terminal.

    运行sudo apachectl重新启动将执行重新启动。目前,opencpu没有特殊的init或systemd脚本,包括在rpm中,但是基本上ubuntu上的脚本所做的就是重新启动apache并向终端打印一些消息。

  • The REnviron file is only for environment variables. You need to use RProfile for custom code. See also help. Maybe it doesn't get loaded in the right environment. Try: load(file, envir = globalenv(), verbose = TRUE).

    r环境文件仅用于环境变量。您需要使用RProfile来定制代码。看到也有帮助。也许它不会在正确的环境中加载。尝试:load(file, envir = globalenv(), verbose = TRUE)。

  • Note that the recommended way to store stuff is by putting it an R package, either as lazyload data or sysdata.rda (see writing R extensions). You can then load or attach the package on startup, or better yet: formally import the dataset from the package that contains your application or R functions.

    注意,推荐的存储方式是将其放入一个R包,要么作为lazyload数据,要么作为sysdata。rda(参见编写R扩展)。然后,您可以在启动时加载或附加包,或者更好:从包含应用程序或R函数的包中正式导入数据集。

  • Afaik, centos runs httpd requests as user apache? What makes you think opencpu runs as root? That is certainly not the intention. On CentOS you sometimes need to play around with SELinux httpd flags to get your applications to work, see also the rpm readme.

    Afaik, centos作为用户apache运行httpd请求?是什么让你认为opencpu是作为根运行的?这当然不是意图。在CentOS上,您有时需要使用SELinux httpd标志来让应用程序工作,请参见rpm readme。

The rpm packages are a bit more recent and less tested than the debian ones, so if you have problems or suggestions, please open an issue on github.

rpm包比debian包更新了一些,测试也少了一些,所以如果您有问题或建议,请在github上打开一个问题。

#1


2  

Some answers

一些答案

  • Running sudo apachectl restart will do the restart. There is currently no special init or systemd script for opencpu included with the rpm, but basically all that script does on ubuntu is restart apache and print some messages to the terminal.

    运行sudo apachectl重新启动将执行重新启动。目前,opencpu没有特殊的init或systemd脚本,包括在rpm中,但是基本上ubuntu上的脚本所做的就是重新启动apache并向终端打印一些消息。

  • The REnviron file is only for environment variables. You need to use RProfile for custom code. See also help. Maybe it doesn't get loaded in the right environment. Try: load(file, envir = globalenv(), verbose = TRUE).

    r环境文件仅用于环境变量。您需要使用RProfile来定制代码。看到也有帮助。也许它不会在正确的环境中加载。尝试:load(file, envir = globalenv(), verbose = TRUE)。

  • Note that the recommended way to store stuff is by putting it an R package, either as lazyload data or sysdata.rda (see writing R extensions). You can then load or attach the package on startup, or better yet: formally import the dataset from the package that contains your application or R functions.

    注意,推荐的存储方式是将其放入一个R包,要么作为lazyload数据,要么作为sysdata。rda(参见编写R扩展)。然后,您可以在启动时加载或附加包,或者更好:从包含应用程序或R函数的包中正式导入数据集。

  • Afaik, centos runs httpd requests as user apache? What makes you think opencpu runs as root? That is certainly not the intention. On CentOS you sometimes need to play around with SELinux httpd flags to get your applications to work, see also the rpm readme.

    Afaik, centos作为用户apache运行httpd请求?是什么让你认为opencpu是作为根运行的?这当然不是意图。在CentOS上,您有时需要使用SELinux httpd标志来让应用程序工作,请参见rpm readme。

The rpm packages are a bit more recent and less tested than the debian ones, so if you have problems or suggestions, please open an issue on github.

rpm包比debian包更新了一些,测试也少了一些,所以如果您有问题或建议,请在github上打开一个问题。