Pages

Sunday, 22 August 2021

Shiny Server

 https://www.rstudio.com/products/shiny/shiny-server/

Shiny Server is a server program that makes Shiny applications available over the web.

Features

  • Host multiple Shiny applications, each with its own URL
  • Can be configured to allow any user on the system to create and deploy their own Shiny applications
  • Supports non-websocket-capable browsers, like IE9
  • Free and open source (AGPLv3 license)
  • Pre-built installers for select Linux distributions.

Installing

At this time, Shiny Server can be run on Linux servers with explicit support for Ubuntu 14.04 or greater (64 bit) and CentOS/RHEL 6 (64 bit) or greater. If you are using one of these distributions, please download the pre-packaged installers from RStudio:

Download Shiny Server Installers.

These installers will provide a majority of the prerequisite software and will provision all the necessary directories for you.

If you are not using one of the explicitly supported distributions, you can still use Shiny Server by building it from source, see the instructions for building from source.

Configuration

Shiny Server will use the default configuration unless an alternate configuration is provided at /etc/shiny-server/shiny-server.conf. Using the default configuration, Shiny Server will look for Shiny apps in /srv/shiny-server/ and host them on port 3838. If you plan to host your apps in this directory, you can either copy an app you've already developed to that location:

sudo cp -R ~/MY-APP /srv/shiny-server/

Or you can copy some or all of the examples provided with the Shiny package. (The location of the R library varies from system to system. You can use the command R -e ".libPaths()" --quiet to print the directory of the R library.) For instance, on Ubuntu, you could execute cp -R /usr/local/lib/R/site-library/shiny/examples/* /srv/shiny-server/.

Now start a web browser and point it to http://<hostname>:3838/APP_NAME/

If the browser is not able to connect to the server, configure your server's firewall to allow inbound TCP connections on port 3838.

To customize any of the above, or to explore the other ways Shiny Server can host Shiny apps, see the Shiny Server Configuration Reference for details on the various ways Shiny Server can be configured.

Documentation & Contact & Support

See the Administrator's Guide to Shiny Server for more complete documentation regarding the setup and management of Shiny Server.

Please direct questions to the Shiny Community discussion board. If you're interested in Professional Support, please look at our commercial Shiny Server Pro product.


from https://github.com/rstudio/shiny-server

-----


Building Shiny Server from Source


RStudio provides some pre-compiled installers for Shiny Server. If you're using Ubuntu 14.04+ (64 bit) or CentOS/RHEL 6+ (64 bit), or SLES 12, we recommend that you use one of these pre-built installers. If you're on a different distribution or prefer to build from source, these instructions may help.

Prerequisites

The following software must be available on the system before continuing:

  • Python 3.6+
  • cmake
  • gcc (gcc 4.8 or newer is required)
  • g++ (g++ 4.8 or newer is required)
  • git
  • R-base-devel - Many distributions provide two packages when distributing R: one for base R and one "devel" package which is helpful in building extra packages, among other things. In addition to base R, Shiny Server requires many of the components typically included in the "devel" packages, such as libpng and libjpg. If you're on a platform that doesn't have such a "devel" package, be sure to include these components when installing R.

Finally, you must install the Shiny package in the system-wide library. One way to do that is the following command:

sudo su - -c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""

Note that you may need to download the package and install it from the command line if you're using an older version of R that doesn't support installation from an HTTPS CRAN repo, or use un-encrypted HTTP (insecure).

Installation

Once all of the prerequisites have been satisfied, you can use the following commands to download and install Shiny Server.

# Clone the repository from GitHub
git clone https://github.com/rstudio/shiny-server.git

# Get into a temporary directory in which we'll build the project
cd shiny-server
mkdir tmp
cd tmp

# Install our private copy of Node.js
../external/node/install-node.sh

# Add the bin directory to the path so we can reference node
DIR=`pwd`
PATH=$DIR/../bin:$PATH

# Use cmake to prepare the make step. Modify the "--DCMAKE_INSTALL_PREFIX"
# if you wish the install the software at a different location.
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../
# Get an error here? Check the "How do I set the cmake Python version?" question below

# Recompile the npm modules included in the project
make
mkdir ../build
(cd .. && ./bin/npm install)
(cd .. && ./bin/node ./ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild)

# Install the software at the predefined location
sudo make install

# Install default config file
sudo mkdir -p /etc/shiny-server
sudo cp ../config/default.config /etc/shiny-server/shiny-server.conf

At this point, you've successfully installed Shiny Server! You'll still need to configure a few directories and other assets in order for Shiny Server to work properly, however. We'll do this in the next section.

Post-Install

Shiny Server will look for resources in specific locations. Some of these (log directories, application directories, etc.) can be modified using a configuration file stored at /etc/shiny-server/shiny-server.conf. If no such file is provided, the default configuration will be used. The following commands prepare a system for such a configuration.

# Place a shortcut to the shiny-server executable in /usr/bin
sudo ln -s /usr/local/shiny-server/bin/shiny-server /usr/bin/shiny-server

# Create shiny user. On some systems, you may need to specify the full path to 'useradd'
sudo useradd -r -m shiny

# Create log, config, and application directories
sudo mkdir -p /var/log/shiny-server
sudo mkdir -p /srv/shiny-server
sudo mkdir -p /var/lib/shiny-server
sudo chown shiny /var/log/shiny-server
sudo mkdir -p /etc/shiny-server

At this point, you should be able to follow the Configuration section of the README to begin serving some Shiny applications. You should be able to start the server from the command line by executing shiny-server (either as the shiny user, or as root). If you'd like Shiny Server to start automatically when your machine is booted, see the associated question in the F.A.Q. below.

Frequently Asked Questions

How can I make Shiny Server start automatically?

For systems that run systemd or upstart, you can find sample scripts in the subdirectories of this: https://github.com/rstudio/shiny-server/tree/master/config

See your operating system's documentation for instructions on installing and enabling systemd/upstart scripts.

If your distribution does not use systemd or upstart, you'll likely need to create an init.d script for Shiny Server. We provide some init.d scripts here that may serve as a useful guide for you, but they may need some modification to work as expected on your distribution. Unfortunately, because the init.d files vary from distribution to distribution, we aren't able to provide exhaustive documentation on how to make this work on your particular setup. Once properly configured, you can run sudo /etc/init.d/shiny-server start to manually start Shiny Server.


from https://github.com/rstudio/shiny-server/wiki/Building-Shiny-Server-from-Source

-----


related post; https://briteming.blogspot.com/2021/08/wechatscope.html

No comments:

Post a Comment