3

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() 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.
  • 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.

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

Many thanks, --Mel.

mbacou
  • 131
  • 8

1 Answers1

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.

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

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

Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
  • Thanks, that clarified it all. I built and loaded a separate data package as suggested, and that works and is much more streamlined than editing custom directives in `Rprofile`. I was confused with OpenCPU running as root (I do have an httpd process running as root, but turned out not to be related). Documentation on configuring persistent variables and datasets with OpenCPU is a bit scattered, took me a while to locate the best approach. Might be useful to add a section to OpenCPU Server Manual. – mbacou Nov 03 '14 at 10:28
  • Yes I know I'm bad at documentation. Maybe start a wiki or so for people to help create some manuals. – Jeroen Ooms Nov 03 '14 at 19:01
  • Did you find a way to configure opencpu on CentOS6 to run user libraries: server.com/ocpu/user//library? This seems to work when user = apache but not otherwise. – user338714 Feb 03 '15 at 17:04
  • @user338714 what error are you getting? Did you [read about SELinux](https://github.com/jeroenooms/opencpu-server/tree/master/rpm)? – Jeroen Ooms Feb 03 '15 at 18:45
  • Yes, I followed the instructions to build and install on CentOS6 (I'm using a RHEL machine) and disabled SELinux for now. When I try to view libraries under a user, I get a message that the user is not found, except for the apache user where it says no libraries are found. The machine also has rstudio server and shiny server running, and I was hoping to use opencpu similar to the per_user shiny setup. Everything works fine if I don't include ../user//.. in the url. – user338714 Feb 04 '15 at 01:54