Thanks, Jeff – The local script.sh.erb remains pretty faithful to the osc repo version.
What I’ve done is attempted to strip out the ruby conditionals, to aid my understanding.
I’m still confused over how the reverse proxy is supported with only the use of a “basic” template, from the submit.yml.erb.
And the rserver signin: how does that work? I’m hoping that knowing the procedure will help understand the bindings required to implement the server. Particularly, why am I still not finding the rserver.log?
Thanks
#!/usr/bin/env bash
<%-
session_dir = session.staged_root
%>
Load the required environment
setup_env () {
export WORKING_DIR=“<%= session_dir %>”
module purge
The rserver container module should set these environment variables:
SINGULARITY_BINDPATH=“/etc,/media,/mnt,/opt,/run,/srv,/usr,/var,/users”
RSTUDIO_SERVER_IMAGE=“/usr/local/project/ondemand/singularity/rstudio/rstudio_launcher_centos7.simg”
PATH=“$PATH:/path/to/R:/path/to/rstudio/rserver”
export RSTUDIO_SERVER_IMAGE=“/home/mrd20/hpcdemo/rstudio/rstudio-launcher-centos-8.sif”
export SINGULARITY_BINDPATH=“/scratch,/usr/local”
export PATH=“$PATH:/usr/local/easybuild/software/RStudio-Server/1.4.1717-foss-2021a-Java-11-R-4.1.0/bin”
SINGULARITY_BINDPATH is being used to bind all RStudio’s requirements from
the host into the guest, and so those values may vary between sites.
module load ondemand-vnc/2.0
module load singularity/3.8.6
module load RStudio-Server/1.4.1717-foss-2021a-Java-11-R-4.1.0
which rsession
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
export SINGULARITYENV_LD_LIBRARY_PATH=“$LD_LIBRARY_PATH”
}
setup_env
Start RStudio Server
PAM auth helper used by RStudio
export RSTUDIO_AUTH=“$WORKING_DIR/bin/auth”
Generate an rsession
wrapper script
export RSESSION_WRAPPER_FILE=“$WORKING_DIR/rsession.sh”
(
umask 077
sed ‘s/^ {2}//’ > “$WORKING_DIR/rsession.sh” << EOL
#!/usr/bin/env bash
Log all output from this script
export RSESSION_LOG_FILE=“$WORKING_DIR/rsession.log”
exec &>>“${RSESSION_LOG_FILE}”
set -x
rsession.sh doesn’t share the same env as the outside script, so these
need to be set explicitly
export R_LIBS_SITE=“${R_LIBS_SITE}”
export TZ=“US/Eastern”
export HOME=“$HOME”
export MODULEPATH_ROOT=“$MODULEPATH_ROOT”
export MODULEPATH=“$MODULEPATH”
export LMOD_PKG=“$LMOD_PKG”
env
Launch the original command
echo “Launching rsession…”
wrsession=which rsession
echo “which rsession? $wrsession?”
exec rsession --r-libs-user “${R_LIBS_USER}” “${@}”
EOL
)
chmod 700 “$WORKING_DIR/rsession.sh”
Set working directory to home directory
echo “Home check:\nHOME is: $HOME\nSHOME is $SINGULARITY_HOME”
cd “${SINGULARITY_HOME}”
Output debug info
hostname
whoami
echo “$USER”
rstudio runtime stuff
echo -e “provider=sqlite\ndirectory=$TMPDIR/db” >> $TMPDIR/db.conf
mkdir “$TMPDIR/run”
mkdir “$TMPDIR/lib”
server log directory in this job’s working directory
mkdir -p “$WORKING_DIR/logs”
set -x
Launch the RStudio Server
Prepare temp directory for sqlite db and conf
echo “Temp directory for db: $TMPDIR”
#echo “create var directory under WORKING_DIR”
#mkdir “$WORKING_DIR/var”
echo “Starting up rserver… at $(date)”
#SINGULARITYENV_LD_LIBRARY_PATH=“$LD_LIBRARY_PATH”
singularity run
-B “$TMPDIR:/tmp”
-B “$WORKING_DIR”
-B “$TMPDIR/lib:/var/lib/rstudio-server”
-B /home
“$RSTUDIO_SERVER_IMAGE”
–www-port “${port}”
–auth-none 0
–auth-pam-helper-path “${RSTUDIO_AUTH}”
–auth-encrypt-password 0
–rsession-path “${RSESSION_WRAPPER_FILE}”
–database-config-file “/tmp/db.conf”
–server-data-dir “/tmp/run”
–server-user=$(whoami)
–secure-cookie-key-file “/tmp/rstudio-server/secure-cookie-key” \
echo ‘Singularity as exited…’