linux:shiny_server
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン | |||
linux:shiny_server [2020/11/24 13:21] – 削除 Wiki Editor | linux:shiny_server [2020/11/24 13:22] (現在) – 作成 Wiki Editor | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== Shiny Server ====== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | RでWebアプリケーションを開発するためのパッケージShinyをWebアプリケーションとして動作させるためのサーバ。オンプレミスの有償版は金額が高く、ホスティングサービスは無償アカウントもあるがデータを外部のサーバに置くのは問題が多いため、オープンソース版を使う。いくつかのOSではパッケージが用意されているが、Gentoo向けには無いのでソースからビルドする。 | ||
+ | |||
+ | ===== 事前準備 ===== | ||
+ | Pythonと親和性が高いGentooでは特に事前にインストールするものはない。R自体はインストールする必要がある。 | ||
+ | |||
+ | |||
+ | ===== ビルドとインストール ===== | ||
+ | 基本的にマニュアル通り。以前は1ステップ必要な手順が抜けていて、コミュニティの書き込みを参照する必要があったが、修正されているようだ。 | ||
+ | |||
+ | > git clone https:// | ||
+ | > cd shiny-server | ||
+ | > mkdir tmp | ||
+ | > cd tmp | ||
+ | > ../ | ||
+ | | ||
+ | # 環境変数をセット | ||
+ | > DIR=`pwd` | ||
+ | > PATH=$DIR/ | ||
+ | > cmake -DCMAKE_INSTALL_PREFIX=/ | ||
+ | | ||
+ | > make | ||
+ | > mkdir ../build | ||
+ | > (cd .. && ./bin/npm install) | ||
+ | > (cd .. && ./bin/node ./ | ||
+ | > make install | ||
+ | | ||
+ | # 設定ファイルを配置するディレクトリの作成 | ||
+ | > mkdir / | ||
+ | > cp ../ | ||
+ | |||
+ | shinyユーザを作成し、各種ディレクトリ等を作成する。 | ||
+ | |||
+ | 今回は、/ | ||
+ | |||
+ | * ${shiny_home}/ | ||
+ | * ${shiny_home}/ | ||
+ | * ${shiny_home}/ | ||
+ | * ${shiny_home}/ | ||
+ | |||
+ | ===== 設定 ===== | ||
+ | / | ||
+ | |||
+ | マニュアルにはないが、bookmarksディレクトリを書き込み可能な形で設定しておかないと、サーバが起動しない。 | ||
+ | |||
+ | # Instruct Shiny Server to run applications as the user " | ||
+ | run_as shiny; | ||
+ | | ||
+ | # Define a server that listens on port 3838 | ||
+ | server { | ||
+ | listen 3838 0.0.0.0; | ||
+ | | ||
+ | # Define a location at the base URL | ||
+ | location / { | ||
+ | | ||
+ | # Host the directory of Shiny Apps stored in this directory | ||
+ | site_dir / | ||
+ | | ||
+ | # Log all Shiny output to files in this directory | ||
+ | log_dir / | ||
+ | | ||
+ | # Bookmark dir | ||
+ | bookmark_state_dir / | ||
+ | | ||
+ | # When a user visits the base URL rather than a particular application, | ||
+ | # an index of the applications available in this directory will be shown. | ||
+ | directory_index on; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | ===== 起動スクリプト ===== | ||
+ | Gentoo OpenRC用の起動スクリプト。 | ||
+ | |||
+ | 注意点は、start-stop-daemonのオプション「--background」「--make-pidfile」をつけておくこと。 | ||
+ | |||
+ | shinyは勝手にバックグラウンドにならないのでbackgroundオプションで切り離し、 pidファイルも生成しないのでmake-pidfileでpidfileオプションで指定した場所にpidファイルを吐き出させる。これでstop関数が正常に動作する。 | ||
+ | |||
+ | |||
+ | |||
+ | # | ||
+ | # Copyright 1999-2016 Gentoo Foundation | ||
+ | # Distributed under the terms of the GNU General Public License v2 | ||
+ | | ||
+ | description=" | ||
+ | pidfile="/ | ||
+ | command="/ | ||
+ | | ||
+ | depend() { | ||
+ | use net | ||
+ | } | ||
+ | | ||
+ | start() { | ||
+ | ebegin " | ||
+ | start-stop-daemon --start --quiet --background --make-pidfile --pidfile ${pidfile} --exec ${command} \ | ||
+ | >> / | ||
+ | eend $? | ||
+ | } | ||
+ | | ||
+ | stop() { | ||
+ | ebegin " | ||
+ | start-stop-daemon --stop --quiet --pidfile ${pidfile} | ||
+ | eend $? | ||
+ | } | ||
+ | |||
linux/shiny_server.txt · 最終更新: 2020/11/24 13:22 by Wiki Editor