问题
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.
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. - (maybe related to above) I am using
load()
andreadRDS()
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. - on Ubuntu OpenCPU seems configured to run under an
opencpu
user. On CentOS6 it seems to run underroot
after installation. I'd like to modify that, but not sure how.
Just wondering if someone has has success configuring OpenCPU on CentOS6.
Many thanks, --Mel.
回答1:
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.The
REnviron
file is only for environment variables. You need to useRProfile
for custom code. See also help. Maybe it doesn't get loaded in the right environment. Try: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.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.
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.
来源:https://stackoverflow.com/questions/26706178/how-to-start-stop-flush-opencpu-on-centos6