Created
November 30, 2018 08:27
-
-
Save grst/6b40ce114f8f83f2c693a207040ce5bf to your computer and use it in GitHub Desktop.
Use conda-env for rstudio-server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER=`whoami` | |
source /etc/profile | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
source /storage/apps/dotfiles/bashrc.sh | |
# load conda env from file | |
CONDA_ENV=`cat /tmp/rstudio-server/${USER}_current_env` | |
echo "## CONDA ENV is >>>" | |
echo ${CONDA_ENV} | |
conda activate ${CONDA_ENV} | |
/usr/lib/rstudio-server/bin/rsession $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | |
USER=`whoami` | |
# set a user-specific secure cookie key | |
COOKIE_KEY_PATH=/tmp/rstudio-server/${USER}_secure-cookie-key | |
rm -f $COOKIE_KEY_PATH | |
uuid > $COOKIE_KEY_PATH | |
chmod 600 $COOKIE_KEY_PATH | |
# store the currently activated conda environment in a file to be ready by rsession.sh | |
CONDA_ENV_PATH=/tmp/rstudio-server/${USER}_current_env | |
rm -f $CONDA_ENV_PATH | |
echo "## Current env is >>" | |
echo $CONDA_PREFIX | |
echo $CONDA_PREFIX > $CONDA_ENV_PATH | |
/usr/lib/rstudio-server/bin/rserver --server-daemonize=0 \ | |
--www-port $1 \ | |
--secure-cookie-key-file $COOKIE_KEY_PATH \ | |
--rsession-which-r=$(which R) \ | |
--rsession-ld-library-path=$CONDA_PREFIX/lib \ | |
--rsession-path="$CWD/rsession.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment