Skip to content

Commit a41be4a

Browse files
Merge branch 'release/0.15.0'
2 parents 9f76e65 + d390d04 commit a41be4a

File tree

5 files changed

+94
-28
lines changed

5 files changed

+94
-28
lines changed

NEWS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## Version 0.15.0 [2024-01-16]
2+
3+
### New Features
4+
5+
* Now `rsc config` reports also on `RSC_*` environment variables.
6+
7+
* The default name of the login hostname suggested in remote SSH
8+
sessions can now be set via environment variable
9+
`RSC_SSH_LOGIN_HOSTNAME`. The default is still to infer it from
10+
`who`.
11+
12+
### Miscellaneous
13+
14+
* `rsc start --dryrun` is now shortened to 10 seconds.
15+
16+
### Bug Fixes
17+
18+
* When adding option `--debug` to `rsc start` the RStudio Server
19+
failed to launch.
20+
21+
122
## Version 0.14.4 [2024-01-16]
223

324
### Bug Fixes

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.14.4.tar.gz
337-
$ tar xf 0.14.4.tar.gz
338-
$ PATH=/path/to/softwarerstudio-server-controller-0.14.4/bin:$PATH
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
339339
$ export PATH
340340
$ rsc --version
341-
0.14.4
341+
0.15.0
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.14.4
349+
rsc: 0.15.0
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/conditions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@ function relay_condition {
123123

124124

125125
function prune_debug {
126-
sed '/DEBUG:/,$d' <<< "${1}"
126+
printf "%s\n" "$@" | sed '/DEBUG:/d' | sed -E 's/\x1b(\[[0-9;]*m|\(B)//g'
127127
}

bin/rsc

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

@@ -315,7 +315,7 @@ function remove_stray_pid_file {
315315
local -i pid
316316
local rserver_hostname
317317
local what
318-
local res
318+
local -a res
319319
local -i okay
320320

321321
what=${1:?}
@@ -365,13 +365,13 @@ function remove_stray_pid_file {
365365

366366
## If this process is not running, remove the PID file
367367
warn_if_check_pid_needs_ssh "${rserver_hostname}"
368-
res=$(check_pid "${pid}" "${rserver_hostname}" 2>&1)
368+
mapfile -t res < <(check_pid "${pid}" "${rserver_hostname}" 2>&1)
369369
okay=$?
370-
mdebug " - checkpid() exit code: ${okay}"
371-
relay_condition "${res}"
372-
res=$(prune_debug "${res}")
373-
pid=${res}
374-
if [[ -z ${pid} ]]; then
370+
mdebug " - checkpid('${pid}', '${rserver_hostname}') exit code: ${okay}"
371+
relay_condition "${res[@]}"
372+
mapfile -t res < <(prune_debug "${res[@]}")
373+
374+
if [[ ${#res[@]} -eq 0 ]]; then
375375
rm "${pid_file}"
376376
warn "Detected a stray PID file (${pid_file}). This file was removed, because it referred to a ${what} process (PID ${pid} on ${rserver_hostname}) which is no longer running."
377377
return 0
@@ -530,8 +530,8 @@ function check_pid {
530530
#shellcheck disable=SC2029
531531
res=$(ssh -o ConnectTimeout="$(ssh_timeout)" "${hostname}" "[[ -d '/proc/${pid}' ]] && echo true || echo false" 2>&1)
532532
okay=$?
533-
mdebug "- Result: ${res}"
534533
mdebug "- Exit code: ${okay}"
534+
mdebug "- Result: ${res}"
535535
if [[ ${okay} -ne 0 ]]; then
536536
## Remove empty leading lines
537537
res=$(sed -e '/./,$!d' <<< "${res}")
@@ -616,12 +616,16 @@ function find_login_host_via_who {
616616
function find_login_host {
617617
local host
618618
local full
619-
host=${LOGIN_HOSTNAME}
620-
619+
620+
## 1. Use 'RSC_SSH_LOGIN_HOSTNAME', if set
621+
host=${RSC_SSH_LOGIN_HOSTNAME}
622+
623+
## 2. Otherwise, infer from 'who'
621624
if [[ -z "${host}" ]]; then
622625
host=$(find_login_host_via_who)
623626
fi
624627

628+
## 3. Fall back to template instructions
625629
if [[ -z "${host}" ]]; then
626630
host="<login-machine>"
627631
fi
@@ -632,6 +636,7 @@ function find_login_host {
632636
host=$(echo "${full}" | cut -d ' ' -f 1)
633637
fi
634638
fi
639+
635640
echo "${host}"
636641
}
637642

@@ -645,7 +650,8 @@ function rs_process_status {
645650
local pid_info
646651
local pid_stats
647652
local tmp
648-
local res
653+
local -i okay
654+
local -a res
649655
pid=${1}
650656
hostname=${2}
651657

@@ -654,13 +660,16 @@ function rs_process_status {
654660
## Check if PID is still active?
655661
if [[ ${pid} -ne 0 ]]; then
656662
warn_if_check_pid_needs_ssh "${hostname}"
657-
res=$(check_pid "${pid}" "${rserver_hostname}" 2>&1)
663+
mapfile -t res < <(check_pid "${pid}" "${rserver_hostname}" 2>&1)
658664
okay=$?
659-
relay_condition "${res}"
660-
res=$(prune_debug "${res}")
661-
pid=${res}
665+
mdebug " - checkpid('${pid}', '${rserver_hostname}') exit code: ${okay}"
666+
mapfile -t res < <(prune_debug "${res[@]}")
667+
if [[ -n "${res[0]}" ]]; then
668+
pid="${res[0]}"
669+
else
670+
pid=0
671+
fi
662672
fi
663-
664673

665674
if [[ ${pid} -ne 0 ]]; then
666675
pid_info="PID ${pid}"
@@ -687,7 +696,7 @@ function rsession_timeout {
687696
local timeout
688697
local bfr
689698
timeout=${RSC_RSESSION_TIMEOUT}
690-
699+
691700
if [[ -z "${timeout}" ]]; then
692701
## The default is 120 minutes (2 hours)
693702
timeout=120
@@ -1054,7 +1063,7 @@ function launch_rserver {
10541063
mdebug "rserver --config-file=\"${workdir}/rserver.conf\" &"
10551064
if $dryrun; then
10561065
echo "DRYRUN: rserver --config-file=\"${workdir}/rserver.conf\""
1057-
sleep 60 &
1066+
sleep 10 &
10581067
else
10591068
rserver --config-file="${workdir}/rserver.conf" &
10601069
fi
@@ -1205,7 +1214,7 @@ function launch_rserver_monitor {
12051214
pid_file=$(rserver_monitor_pid_file)
12061215
if $dryrun; then
12071216
echo "DRYRUN: rserver_monitor launched"
1208-
sleep 60 &
1217+
sleep 10 &
12091218
else
12101219
rserver_monitor &
12111220
fi
@@ -1405,7 +1414,6 @@ ssh=${RSC_SSH:-true}
14051414
## behavior prevents R from seeing, for instance, environment variables
14061415
## set by a job scheduler.
14071416
rsession_inherit_env_pattern=${RSC_ENV_PATTERN:-"^.+$"}
1408-
14091417

14101418
# Parse command-line options
14111419
while [[ $# -gt 0 ]]; do
@@ -1540,6 +1548,15 @@ mdebug "auth: ${auth}"
15401548
mdebug "RSC_AUTH_ARG_2: ${RSC_AUTH_ARG_2}"
15411549
mdebug "revtunnel: [n=${#revtunnel[@]}] ${revtunnel[*]}"
15421550
mdebug "ssh: ${ssh}"
1551+
mdebug "RSC_AUTH: ${RSC_AUTH:-<not set>}"
1552+
mdebug "RSC_ENV_PATTERN: ${RSC_ENV_PATTERN:-<not set>}"
1553+
mdebug "RSC_LOCALPORT: ${RSC_LOCALPORT:-<not set>}"
1554+
mdebug "RSC_PORT: ${RSC_PORT:-<not set>}"
1555+
mdebug "RSC_RSERVER_TIMEOUT: ${RSC_RSERVER_TIMEOUT:-<not set>}"
1556+
mdebug "RSC_RSESSION_TIMEOUT: ${RSC_RSESSION_TIMEOUT:-<not set>}"
1557+
mdebug "RSC_SSH: ${RSC_SSH:-<not set>}"
1558+
mdebug "RSC_SSH_LOGIN_HOSTNAME: ${RSC_SSH_LOGIN_HOSTNAME:-<not set>}"
1559+
mdebug "RSC_SSH_TIMEOUT: ${RSC_SSH_TIMEOUT:-<not set>}"
15431560
mdebug "args: [n=${#args[@]}] ${args[*]}"
15441561

15451562
## Enable terminal colors, if supported
@@ -1558,6 +1575,23 @@ fi
15581575
if [[ "${action}" == "config" ]]; then
15591576
files=()
15601577

1578+
echo "RStudio Server Controller Settings:"
1579+
echo "RSC_AUTH: ${RSC_AUTH:-<not set>}"
1580+
echo "RSC_ENV_PATTERN: ${RSC_ENV_PATTERN:-<not set>}"
1581+
echo "RSC_LOCALPORT: ${RSC_LOCALPORT:-<not set>}"
1582+
value=${RSC_PASSWORD:-<not set>}
1583+
if [[ ${value} != "<not set>" ]] && [[ ${value} != "random" ]]; then
1584+
value="<masked>"
1585+
fi
1586+
echo "RSC_PASSWORD: ${value}"
1587+
echo "RSC_PORT: ${RSC_PORT:-<not set>}"
1588+
echo "RSC_RSERVER_TIMEOUT: ${RSC_RSERVER_TIMEOUT:-<not set>}"
1589+
echo "RSC_RSESSION_TIMEOUT: ${RSC_RSESSION_TIMEOUT:-<not set>}"
1590+
echo "RSC_SSH: ${RSC_SSH:-<not set>}"
1591+
echo "RSC_SSH_LOGIN_HOSTNAME: ${RSC_SSH_LOGIN_HOSTNAME:-<not set>}"
1592+
echo "RSC_SSH_TIMEOUT: ${RSC_SSH_TIMEOUT:-<not set>}"
1593+
1594+
echo
15611595
echo "RStudio Server Controller Storage:"
15621596
echo "XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-<not set>}"
15631597

@@ -1802,7 +1836,7 @@ elif [[ "${action}" == "start" ]]; then
18021836
pid_file=$(ssh_revtunnel_pid_file)
18031837
if $dryrun; then
18041838
echo "DRYRUN: ssh -o ConnectTimeout=\"$(ssh_timeout)\" -N -R \"${rev_spec}\" \"${rev_hostname}\""
1805-
sleep 60 &
1839+
sleep 10 &
18061840
else
18071841
mdebug "ssh -o ConnectTimeout=\"$(ssh_timeout)\" -N -R \"${rev_spec}\" \"${rev_hostname}\""
18081842
printf "%s\n%s\n" "${rev_hostname}" "${rev_port}" > "$(ssh_revtunnel_spec_file)"

tests/rsc.bats

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ teardown() {
115115
assert_success
116116
}
117117

118+
119+
@test "rsc start --dryrun works" {
120+
run rsc start --dryrun 2>&1
121+
assert_failure
122+
assert_output --partial "DRYRUN: rserver --config-file="
123+
assert_output --partial "DRYRUN: rserver_monitor launched"
124+
assert_output --partial "ERROR: It looks like the RStudio Server failed during launch"
125+
assert_output --partial "Shutting down RStudio Server ..."
126+
assert_output --partial "Shutting down RStudio Server ... done"
127+
}
128+
118129
@test "rsc start --debug --dryrun works" {
119130
run rsc start --debug --dryrun 2>&1
120131
assert_failure

0 commit comments

Comments
 (0)