User Tools

Site Tools


wiki:r:shiny

Shiny-Server (R-Statistics)

Install

Get Source Code

  $ pac gcc6
  #
  $ cd ~/abs
  $ wget https://aur.archlinux.org/cgit/aur.git/snapshot/shiny-server-git.tar.gz
  $ tar -xvzf shiny-server-git.tar.gz

Edit PKGBUILD

  $ vim ~/abs/shiny-server/PKGBUILD # change gcc5 to gcc6
 
# Maintainer: Stephen Martin <stephensrmmartin at gmail dot com>
# Changed: Andreas Schild, 14-11-2017 gcc5 to gcc6, gcc-5 to gcc-6,g++-5 to g++-6
pkgname=shiny-server-git
pkgver=20160223
pkgrel=1
pkgdesc="Open-source version of the shiny web development framework server"
arch=('i686' 'x86_64')
url="http://www.rstudio.com/shiny/server/install-opensource"
license=('AGPL')
depends=('r')
makedepends=('git' 'python2' 'cmake' 'r' 'gcc6')
install='accounts.install'
backup=('etc/shiny-server/shiny-server.conf')
source=('shiny-server::git+https://github.com/rstudio/shiny-server.git' 
        'shiny-server.service')
 
 
pkver(){
  cd "$srcdir/$pkgname"
  git describe --long|sed -E 's/([^-]*-g)/r\1/;s/-/./g'
}
 
_gitroot=https://github.com/rstudio/shiny-server.git
_gitname=shiny-server
prepare(){
  # Vigorously force the use of python2
  cd $srcdir
  find -type f -exec sed \
        -e 's_^#!/usr/bin/env python$_&2_' \
            -e 's_^\(#!/usr/bin/python2\).[45]$_\1_' \
                -e 's_^#!/usr/bin/python$_&2_' \
                    -e "s_'python'_'python2'_" -i {} \;
  }
 
build() {
  cd "$srcdir/$_gitname"
  mkdir tmp
  cd tmp
  # More python2 hackery
  DIR=`pwd`
  PATH=$DIR/../bin/:$PATH
  ln -s `which python2` ../bin/python
  export _PYTHON=`which python2`
  export PYTHON=`which python2`
 
  # Node fails with gcc7
  export CC=/bin/gcc-6
  export CXX=/bin/g++-6
 
  # CMake
  cmake -DCMAKE_INSTALL_PREFIX=/usr -DPYTHON="$_PYTHON" ../
  make
 
  mkdir ../build
  (cd .. && bin/npm --python="$PYTHON" install)
  (cd .. && bin/node ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js --python="$PYTHON" rebuild)
}
 
package() {
  cd "$srcdir/$_gitname/tmp"
  make DESTDIR="$pkgdir/" install
  mkdir -p $pkgdir/usr/bin/
  mkdir -p $pkgdir/etc/shiny-server/
  ln -s /usr/shiny-server/bin/shiny-server $pkgdir/usr/bin/shiny-server
  install -m 644 -D $srcdir/shiny-server.service $pkgdir/usr/lib/systemd/system/shiny-server.service
  install -m 644 -D $srcdir/$_gitname/config/default.config $pkgdir/etc/shiny-server/shiny-server.conf
}
 
# vim:set ts=2 sw=2 et:
md5sums=('SKIP'
         '78811ea3ebc75bf875e13e202e4587ae')

Compile Shiny Server

  $ cd ~/abs/shiny-server-git
  $ makepkg -scf
  $ sudo pacman -U shiny-server-git-20??????-?-x86_64.pkg.tar.xz

Install Shiny Server & Shiny

  # Install Shiny Server
  $ sudo pacman -U shiny-server-git-20??????-?-x86_64.pkg.tar.xz
  #
  # Install Shiny
  # since default CRAN repository is not set, the repos parameter have to be specified
  $ sudo su - -c "R -e \"install.packages('shiny',repos = 'http://cran.us.r-project.org')\""

Start Shiny-Server

  $ sudo systemctl start shiny-server
  $ sudo systemctl status shiny-server
  #  [INFO] shiny-server - Shiny Server v1.5.6.0 (Node.js v6.10.3)
  #  [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
  #  [INFO] shiny-server - Starting listener on 0.0.0.0:3838
  #
  $ sudo systemctl enable shiny-server

Configure Shiny Server

  $ locate shiny-server.conf
  # /etc/shiny-server/shiny-server.conf
  $ sudo vim /etc/shiny-server/shiny-server.conf

Configure NginX

  $ sudo vim /etc/nginx/nginx.conf
  #
http {
# WebSocket Proxying in order to correctly display Shiny apps and R Markdown in Shiny Server:
  map $http_upgrade $connection_upgrade {
      default upgrade;
      ''      close;
    }
# ...
 
  server {
    listen 80;
# ...
 
    # shiny @ geo.bfw.ac.at/shiny/
    location /shiny/ {
      rewrite ^/shiny/(.*)$ /$1 break;
      proxy_pass http://localhost:3838;
      proxy_redirect http://localhost:3838/ $scheme://$host/shiny/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
      proxy_buffering off;
    }
#
# Restart NginX
  $ sudo systemctl restart nginx.service

gfortran

  $ pac gcc-fortran #needed by package dygraphs
wiki/r/shiny.txt · Last modified: 2017/11/16 15:36 by schild