Bhaskar Karambelkar's Blog

Shiny in a SmartOS zone


Tags: R R-Stats SmartOS HowTo Shiny

My Last post showed you how to install R inside a SmartOS zone. This post is about installing the shiny server in the said zone. While setting up R was relatively straight forward, for setting up Shiny server I had to patch some C++ code to make shiny server work on solaris. Which means you don’t have to, just follow along.

First install R in a zone as shown in my earlier post. This is very important, unless you have a working R setup you cannot have a functional working Shiny server. Also make sure to allocate enough CPU, memory, and disk-space for your zone.

# Install some packages
pkgin install git-base
# Install Shiny R package
Rscript -e "install.packages(c('shiny'))"
# Next install the shiny server
mkdir /opt/src && cd /opt/src
git clone
cd shiny-server/
# We need a patch for some solaris specific stuff
git apply solaris.diff && rm solaris.diff
mkdir tmp
cd tmp
PYTHON=`which python`
mkdir ../build
(cd .. && ./bin/npm --python="$PYTHON" rebuild)
(cd .. && ./bin/node ./ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js --python="$PYTHON" rebuild)
# Install the software at the predefined location
make install

This completes installation of shiny server. Next some post installation stuff

ln -s /usr/local/shiny-server/bin/shiny-server /usr/local/bin
useradd -m shiny
mkdir -p /var/log/shiny-server
mkdir -p /srv/shiny-server
mkdir -p /var/lib/shiny-server
chown shiny: /var/log/shiny-server /srv/shiny-server /var/lib/shiny-server
mkdir -p /etc/shiny-server
cd /etc/shiny-server

That’s it, Shiny is installed and configured. To start it

# We run the shiny server as user shiny
su - shiny

You should see something like

[2015-10-25 01:49:43.019] [INFO] shiny-server - Shiny Server v1.4.1.0 (Node.js v0.10.40)
[2015-10-25 01:49:43.021] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2015-10-25 01:49:43.064] [INFO] shiny-server - Starting listener on

Congratulations you now have a running shiny server inside a SmartOS zone. The shiny server installation instructions came from the official docs, but I did have to patch some stuff to make it work under solaris. The patch is available on gist. Next I’ll try and create a proper start-up script for shiny-server so that it can be controlled via svcadm.