Skip to content

Commit b5df9ba

Browse files
Merge branch 'release/0.15.1'
2 parents a41be4a + af7f911 commit b5df9ba

File tree

5 files changed

+90
-28
lines changed

5 files changed

+90
-28
lines changed

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## Version 0.15.1 [2024-01-25]
2+
3+
### New Features
4+
5+
* `rsc config` now also reports on RStudio User Configuration,
6+
e.g. the user preferences `rstudio-prefs.json` file.
7+
8+
* `rsc config` and `rsc status` now report on file sizes and
9+
modification timestamps.
10+
11+
112
## Version 0.15.0 [2024-01-16]
213

314
### New Features

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,20 +333,20 @@ As before, the RStudio Server is available at
333333
334334
```sh
335335
$ cd /path/to/software
336-
$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.15.0.tar.gz
337-
$ tar xf 0.15.0.tar.gz
338-
$ PATH=/path/to/softwarerstudio-server-controller-0.15.0/bin:$PATH
336+
$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.15.1.tar.gz
337+
$ tar xf 0.15.1.tar.gz
338+
$ PATH=/path/to/softwarerstudio-server-controller-0.15.1/bin:$PATH
339339
$ export PATH
340340
$ rsc --version
341-
0.15.0
341+
0.15.1
342342
```
343343
344344
To verify that the tool can find R and the RStudio Server executables,
345345
call:
346346
347347
```sh
348348
$ rsc --version --full
349-
rsc: 0.15.0
349+
rsc: 0.15.1
350350
RStudio Server: 2023.06.2+561 (Mountain Hydrangea) for Linux [/path/to/rstudio-server/bin/rstudio-server]
351351
R: 4.3.1 (2023-06-16) -- "Shortstop Beagle" [/path/to/R/bin/R]
352352
```

bin/incl/files.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,18 @@ function wait_for_file {
4242
done
4343
[[ -f "${file}" ]] || error "Waited for file ${file}, but gave up after ${maxseconds} seconds"
4444
}
45+
46+
function file_info {
47+
local file=${1:?}
48+
local -i size
49+
local timestamp
50+
51+
if [[ -f "${file}" ]]; then
52+
size=$(stat --format="%s" "${file}")
53+
timestamp=$(stat --format="%Y" "${file}")
54+
timestamp=$(date -d "@${timestamp}" "+%F %T")
55+
echo "${size} bytes; ${timestamp})"
56+
else
57+
echo "<not available>"
58+
fi
59+
}

bin/rsc

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
### rsc config --full
6464
### rsc log
6565
###
66-
### Version: 0.15.0
66+
### Version: 0.15.1
6767
### Copyright: Henrik Bengtsson (2022-2024) and Harry Putnam (2022)
6868
### License: ISC
6969

@@ -248,8 +248,17 @@ function make_config_dir {
248248
# -------------------------------------------------------------------------
249249
# RStudio Server configuration file
250250
# -------------------------------------------------------------------------
251+
function rstudio_config_home {
252+
local path
253+
path=${RSTUDIO_CONFIG_HOME}
254+
if [[ -z ${path} ]]; then
255+
path=${XDG_CONFIG_HOME:-$HOME/.config}/rstudio
256+
fi
257+
echo "${path}"
258+
}
259+
251260
# Source: https://docs.rstudio.com/ide/server-pro/r_sessions/workspace_management.html#storage-location-customization
252-
function rstudio_config_dir {
261+
function rstudio_data_home {
253262
local path
254263
path=${RSTUDIO_DATA_HOME}
255264
if [[ -z ${path} ]]; then
@@ -296,12 +305,24 @@ function remove_stray_lockfile {
296305
lockfile=${workdir}/pid.lock
297306

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

300310
## Nothing to do?
301-
[[ ! -f "${lockfile}" ]] || [[ -n "$(rserver_pid true)" ]] || [[ -n "$(rsession_pid true)" ]] || [[ -n "$(ssh_revtunnel_pid true)" ]] && { mdebug "remove_stray_lockfile() ... done"; return 0; }
311+
if [[ ! -f "${lockfile}" ]]; then
312+
mdebug "remove_stray_lockfile() ... done"
313+
return 0
314+
fi
315+
316+
## Is 'rserver', 'rsession', or an SSH reverse tunnel running?
317+
if [[ -n "$(rserver_pid true)" ]] || [[ -n "$(rsession_pid true)" ]] || [[ -n "$(ssh_revtunnel_pid true)" ]]; then
318+
mdebug "- skipping: detected an 'rserver', 'rsession', or an SSH reverse tunnel process running"
319+
mdebug "remove_stray_lockfile() ... done"
320+
return 0
321+
fi
302322

303323
## Here we know that there's neither a rserver PID nor a rsession PID
304324
rm "${lockfile}"
325+
305326
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)."
306327

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

1586+
15651587
## Remove any stray files
15661588
if ! ${force}; then
15671589
mdebug "Removing stray files ..."
@@ -1593,41 +1615,42 @@ if [[ "${action}" == "config" ]]; then
15931615

15941616
echo
15951617
echo "RStudio Server Controller Storage:"
1596-
echo "XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-<not set>}"
1618+
echo "XDG_CONFIG_HOME: ${XDG_CONFIG_HOME:-<not set>}"
15971619

15981620
workdir=$(config_dir)
1599-
echo "config-dir=${workdir}"
1621+
echo "config-dir: ${workdir}"
16001622

1601-
echo "lockfile=${workdir}/pid.lock"
1623+
file=${workdir}/pid.lock
1624+
echo "lockfile: ${file} [$(file_info "${file}")]"
16021625

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

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

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

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

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

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

1627-
echo "rserver-pid-file=$(rserver_pid_file)"
1628-
echo "rsession-pid-file=$(rsession_pid_file)"
1629-
echo "rsession-log-file=${workdir}/rsession.log"
1630-
echo "rserver-monitor-pid-file=$(rserver_monitor_pid_file)"
1650+
echo "rserver-pid-file: $(rserver_pid_file) [$(file_info "${file}")]"
1651+
echo "rsession-pid-file: $(rsession_pid_file) [$(file_info "${file}")]"
1652+
echo "rsession-log-file: ${workdir}/rsession.log [$(file_info "${file}")]"
1653+
echo "rserver-monitor-pid-file: $(rserver_monitor_pid_file) [$(file_info "${file}")]"
16311654

16321655
if $full; then
16331656
echo
@@ -1641,12 +1664,25 @@ if [[ "${action}" == "config" ]]; then
16411664
done
16421665
fi
16431666

1667+
echo
1668+
echo "RStudio User Configuration:"
1669+
echo "XDG_CONFIG_HOME: ${XDG_CONFIG_HOME:-<not set>}"
1670+
echo "RSTUDIO_CONFIG_HOME: ${RSTUDIO_CONFIG_HOME:-<not set>}"
1671+
workdir=$(rstudio_config_home)
1672+
echo "RStudio config home: ${workdir}"
1673+
file=${workdir}/rstudio-prefs.json
1674+
echo "RStudio user preferences: ${file} [$(file_info "${file}")]"
1675+
if $full && [[ -f "${file}" ]]; then
1676+
cat "${file}"
1677+
echo
1678+
fi
1679+
16441680
echo
16451681
echo "RStudio User State Storage:"
1646-
echo "XDG_DATA_HOME=${XDG_DATA_HOME:-<not set>}"
1647-
echo "RSTUDIO_DATA_HOME=${RSTUDIO_DATA_HOME:-<not set>}"
1648-
workdir=$(rstudio_config_dir)
1649-
echo "RStudio config folder=${workdir}"
1682+
echo "XDG_DATA_HOME: ${XDG_DATA_HOME:-<not set>}"
1683+
echo "RSTUDIO_DATA_HOME: ${RSTUDIO_DATA_HOME:-<not set>}"
1684+
workdir=$(rstudio_data_home)
1685+
echo "RStudio data home: ${workdir}"
16501686
if $full && [[ -d "${workdir}" ]]; then
16511687
du --human-readable --si --summarize "${workdir}"/*
16521688
if [[ -d "${workdir}"/sessions/active/ ]]; then
@@ -1685,7 +1721,7 @@ elif [[ "${action}" == "status" ]]; then
16851721
workdir=$(config_dir)
16861722
lockfile=${workdir}/pid.lock
16871723
if [[ -f "${lockfile}" ]]; then
1688-
echo "lock file: exists (${lockfile})"
1724+
echo "lock file: exists (${lockfile} [$(file_info "${lockfile}")])"
16891725
else
16901726
echo "lock file: does not exist"
16911727
fi

tests/rsc.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ teardown() {
8686
assert_success
8787
assert_output --partial "RStudio Server Controller Storage:"
8888
assert_output --partial "RStudio User State Storage:"
89-
assert_output --partial "XDG_CONFIG_HOME=$(dirname "$(mktemp -d)")"
90-
assert_output --partial "XDG_DATA_HOME=$(dirname "$(mktemp -d)")"
89+
assert_output --partial "XDG_CONFIG_HOME: $(dirname "$(mktemp -d)")"
90+
assert_output --partial "XDG_DATA_HOME: $(dirname "$(mktemp -d)")"
9191
}
9292

9393
@test "rsc config --full works" {

0 commit comments

Comments
 (0)