Skip to content

Commit

Permalink
Merge branch 'release/0.15.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Jan 25, 2024
2 parents a41be4a + af7f911 commit b5df9ba
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 28 deletions.
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## Version 0.15.1 [2024-01-25]

### New Features

* `rsc config` now also reports on RStudio User Configuration,
e.g. the user preferences `rstudio-prefs.json` file.

* `rsc config` and `rsc status` now report on file sizes and
modification timestamps.


## Version 0.15.0 [2024-01-16]

### New Features
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,20 +333,20 @@ As before, the RStudio Server is available at
```sh
$ cd /path/to/software
$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.15.0.tar.gz
$ tar xf 0.15.0.tar.gz
$ PATH=/path/to/softwarerstudio-server-controller-0.15.0/bin:$PATH
$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.15.1.tar.gz
$ tar xf 0.15.1.tar.gz
$ PATH=/path/to/softwarerstudio-server-controller-0.15.1/bin:$PATH
$ export PATH
$ rsc --version
0.15.0
0.15.1
```
To verify that the tool can find R and the RStudio Server executables,
call:
```sh
$ rsc --version --full
rsc: 0.15.0
rsc: 0.15.1
RStudio Server: 2023.06.2+561 (Mountain Hydrangea) for Linux [/path/to/rstudio-server/bin/rstudio-server]
R: 4.3.1 (2023-06-16) -- "Shortstop Beagle" [/path/to/R/bin/R]
```
Expand Down
15 changes: 15 additions & 0 deletions bin/incl/files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,18 @@ function wait_for_file {
done
[[ -f "${file}" ]] || error "Waited for file ${file}, but gave up after ${maxseconds} seconds"
}

function file_info {
local file=${1:?}
local -i size
local timestamp

if [[ -f "${file}" ]]; then
size=$(stat --format="%s" "${file}")
timestamp=$(stat --format="%Y" "${file}")
timestamp=$(date -d "@${timestamp}" "+%F %T")
echo "${size} bytes; ${timestamp})"
else
echo "<not available>"
fi
}
78 changes: 57 additions & 21 deletions bin/rsc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
### rsc config --full
### rsc log
###
### Version: 0.15.0
### Version: 0.15.1
### Copyright: Henrik Bengtsson (2022-2024) and Harry Putnam (2022)
### License: ISC

Expand Down Expand Up @@ -248,8 +248,17 @@ function make_config_dir {
# -------------------------------------------------------------------------
# RStudio Server configuration file
# -------------------------------------------------------------------------
function rstudio_config_home {
local path
path=${RSTUDIO_CONFIG_HOME}
if [[ -z ${path} ]]; then
path=${XDG_CONFIG_HOME:-$HOME/.config}/rstudio
fi
echo "${path}"
}

# Source: https://docs.rstudio.com/ide/server-pro/r_sessions/workspace_management.html#storage-location-customization
function rstudio_config_dir {
function rstudio_data_home {
local path
path=${RSTUDIO_DATA_HOME}
if [[ -z ${path} ]]; then
Expand Down Expand Up @@ -296,12 +305,24 @@ function remove_stray_lockfile {
lockfile=${workdir}/pid.lock

mdebug "remove_stray_lockfile() ..."
mdebug "- file: ${lockfile} [$(file_info "${lockfile}")]"

## Nothing to do?
[[ ! -f "${lockfile}" ]] || [[ -n "$(rserver_pid true)" ]] || [[ -n "$(rsession_pid true)" ]] || [[ -n "$(ssh_revtunnel_pid true)" ]] && { mdebug "remove_stray_lockfile() ... done"; return 0; }
if [[ ! -f "${lockfile}" ]]; then
mdebug "remove_stray_lockfile() ... done"
return 0
fi

## Is 'rserver', 'rsession', or an SSH reverse tunnel running?
if [[ -n "$(rserver_pid true)" ]] || [[ -n "$(rsession_pid true)" ]] || [[ -n "$(ssh_revtunnel_pid true)" ]]; then
mdebug "- skipping: detected an 'rserver', 'rsession', or an SSH reverse tunnel process running"
mdebug "remove_stray_lockfile() ... done"
return 0
fi

## Here we know that there's neither a rserver PID nor a rsession PID
rm "${lockfile}"

warn "Detected a stray lock file (${lockfile}). This file was removed, because there was no evidence that another instance was running on this system (no PID files for neither 'rserver' nor 'rsession' were found)."

mdebug "remove_stray_lockfile() ... done"
Expand Down Expand Up @@ -1562,6 +1583,7 @@ mdebug "args: [n=${#args[@]}] ${args[*]}"
## Enable terminal colors, if supported
term_colors enable


## Remove any stray files
if ! ${force}; then
mdebug "Removing stray files ..."
Expand Down Expand Up @@ -1593,41 +1615,42 @@ if [[ "${action}" == "config" ]]; then

echo
echo "RStudio Server Controller Storage:"
echo "XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-<not set>}"
echo "XDG_CONFIG_HOME: ${XDG_CONFIG_HOME:-<not set>}"

workdir=$(config_dir)
echo "config-dir=${workdir}"
echo "config-dir: ${workdir}"

echo "lockfile=${workdir}/pid.lock"
file=${workdir}/pid.lock
echo "lockfile: ${file} [$(file_info "${file}")]"

file=${workdir}/rserver.conf
echo "config-file=${file}"
echo "config-file: ${file} [$(file_info "${file}")]"
files+=("${file}")

file=${workdir}/rsession.conf
echo "config-file=${file}"
echo "config-file: ${file} [$(file_info "${file}")]"
files+=("${file}")

file=${workdir}/rsession.sh
echo "rsession-sh-file=${file}"
echo "rsession-sh-file: ${file} [$(file_info "${file}")]"
files+=("${file}")

file=${workdir}/rserver.sh
echo "rserver-sh-file=${file}"
echo "rserver-sh-file: ${file} [$(file_info "${file}")]"
files+=("${file}")

file=${workdir}/rserver.hostname
echo "rserver-sh-file=${file}"
echo "rserver-sh-file: ${file} [$(file_info "${file}")]"
files+=("${file}")

file=${workdir}/rserver.port
echo "rserver-sh-file=${file}"
echo "rserver-sh-file: ${file} [$(file_info "${file}")]"
files+=("${file}")

echo "rserver-pid-file=$(rserver_pid_file)"
echo "rsession-pid-file=$(rsession_pid_file)"
echo "rsession-log-file=${workdir}/rsession.log"
echo "rserver-monitor-pid-file=$(rserver_monitor_pid_file)"
echo "rserver-pid-file: $(rserver_pid_file) [$(file_info "${file}")]"
echo "rsession-pid-file: $(rsession_pid_file) [$(file_info "${file}")]"
echo "rsession-log-file: ${workdir}/rsession.log [$(file_info "${file}")]"
echo "rserver-monitor-pid-file: $(rserver_monitor_pid_file) [$(file_info "${file}")]"

if $full; then
echo
Expand All @@ -1641,12 +1664,25 @@ if [[ "${action}" == "config" ]]; then
done
fi

echo
echo "RStudio User Configuration:"
echo "XDG_CONFIG_HOME: ${XDG_CONFIG_HOME:-<not set>}"
echo "RSTUDIO_CONFIG_HOME: ${RSTUDIO_CONFIG_HOME:-<not set>}"
workdir=$(rstudio_config_home)
echo "RStudio config home: ${workdir}"
file=${workdir}/rstudio-prefs.json
echo "RStudio user preferences: ${file} [$(file_info "${file}")]"
if $full && [[ -f "${file}" ]]; then
cat "${file}"
echo
fi

echo
echo "RStudio User State Storage:"
echo "XDG_DATA_HOME=${XDG_DATA_HOME:-<not set>}"
echo "RSTUDIO_DATA_HOME=${RSTUDIO_DATA_HOME:-<not set>}"
workdir=$(rstudio_config_dir)
echo "RStudio config folder=${workdir}"
echo "XDG_DATA_HOME: ${XDG_DATA_HOME:-<not set>}"
echo "RSTUDIO_DATA_HOME: ${RSTUDIO_DATA_HOME:-<not set>}"
workdir=$(rstudio_data_home)
echo "RStudio data home: ${workdir}"
if $full && [[ -d "${workdir}" ]]; then
du --human-readable --si --summarize "${workdir}"/*
if [[ -d "${workdir}"/sessions/active/ ]]; then
Expand Down Expand Up @@ -1685,7 +1721,7 @@ elif [[ "${action}" == "status" ]]; then
workdir=$(config_dir)
lockfile=${workdir}/pid.lock
if [[ -f "${lockfile}" ]]; then
echo "lock file: exists (${lockfile})"
echo "lock file: exists (${lockfile} [$(file_info "${lockfile}")])"
else
echo "lock file: does not exist"
fi
Expand Down
4 changes: 2 additions & 2 deletions tests/rsc.bats
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ teardown() {
assert_success
assert_output --partial "RStudio Server Controller Storage:"
assert_output --partial "RStudio User State Storage:"
assert_output --partial "XDG_CONFIG_HOME=$(dirname "$(mktemp -d)")"
assert_output --partial "XDG_DATA_HOME=$(dirname "$(mktemp -d)")"
assert_output --partial "XDG_CONFIG_HOME: $(dirname "$(mktemp -d)")"
assert_output --partial "XDG_DATA_HOME: $(dirname "$(mktemp -d)")"
}

@test "rsc config --full works" {
Expand Down

0 comments on commit b5df9ba

Please sign in to comment.