Skip to content

Commit c629e58

Browse files
Merge branch 'release/0.16.1'
2 parents 739e337 + 98ba367 commit c629e58

File tree

6 files changed

+59
-15
lines changed

6 files changed

+59
-15
lines changed

.github/workflows/shellcheck.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
run: |
2424
sudo apt-get install -y shellcheck
2525
shellcheck --version
26-
curl -L -O https://github.com/koalaman/shellcheck/releases/download/v0.9.0/shellcheck-v0.9.0.linux.x86_64.tar.xz
27-
tar Jxf shellcheck-v0.9.0.linux.x86_64.tar.xz
28-
mv shellcheck-v0.9.0/shellcheck bin
26+
curl -L -O https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz
27+
tar Jxf shellcheck-v0.10.0.linux.x86_64.tar.xz
28+
mv shellcheck-v0.10.0/shellcheck bin
2929
PATH="bin:$PATH" shellcheck --version
3030
3131
- name: ShellCheck

NEWS.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
## Version 0.16.1 [2024-08-20]
2+
3+
### Miscellaneous
4+
5+
* Now the error message that `rsc stop` produces when it failed to
6+
stop an RStudio Server instance running on another machine, will
7+
report on both the machine where it thinks RStudio is running and
8+
the current machine.
9+
10+
* Now `rsc` assert that all files it creates are non-empty. This
11+
helps troubleshooting obscure errors, e.g. when user runs out of
12+
disk space.
13+
14+
### Bug Fixes
15+
16+
* `rsc start --debug` could give an `operand expected (error token is
17+
"<pid>")` error on some systems.
18+
19+
### Deprecated and defunct
20+
21+
* `--port=random` and `--port=uid` are defunct.
22+
23+
124
## Version 0.16.0 [2024-02-01]
225

326
### 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.16.0.tar.gz
337-
$ tar xf 0.16.0.tar.gz
338-
$ PATH=/path/to/softwarerstudio-server-controller-0.16.0/bin:$PATH
336+
$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.16.1.tar.gz
337+
$ tar xf 0.16.1.tar.gz
338+
$ PATH=/path/to/softwarerstudio-server-controller-0.16.1/bin:$PATH
339339
$ export PATH
340340
$ rsc --version
341-
0.16.0
341+
0.16.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.16.0
349+
rsc: 0.16.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/asserts.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ function assert_file_exists {
88
[[ -f "$1" ]] || error "No such file: '$1' (working directory '${PWD}')"
99
}
1010

11+
## Usage: assert_file_is_not_empty /path/to/file
12+
function assert_file_is_not_empty {
13+
[[ $# -ne 1 ]] && error "${FUNCNAME[0]}() requires a single argument: $#"
14+
[[ -n "$1" ]] || error "File name must be non-empty: '$1'"
15+
[[ -f "$1" ]] || error "No such file: '$1' (working directory '${PWD}')"
16+
[[ -s "$1" ]] || error "The file is empty: '$1' (working directory '${PWD}')"
17+
}
18+
1119
function assert_link_exists {
1220
[[ $# -ne 1 ]] && error "${FUNCNAME[0]}() requires a single argument: $#"
1321
[[ -n "$1" ]] || error "File name must be non-empty: '$1'"

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-
printf "%s\n" "$@" | sed '/DEBUG:/d' | sed -E 's/\x1b(\[[0-9;]*m|\(B)//g'
126+
printf "%s\n" "$@" | sed '/DEBUG:/d' | sed 's/\x1b\[[0-9;]*m\x0f//g' | sed -E 's/\x1b(\[[0-9;]*m|\(B)//g'
127127
}

bin/rsc

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

@@ -284,6 +284,7 @@ function acquire_lock_file {
284284
error "${msg}"
285285
fi
286286
echo "${PPID}" > "${lockfile}"
287+
assert_file_is_not_empty "${lockfile}"
287288
}
288289

289290
function remove_lock_file {
@@ -388,7 +389,7 @@ function remove_stray_pid_file {
388389
warn_if_check_pid_needs_ssh "${rserver_hostname}"
389390
mapfile -t res < <(check_pid "${pid}" "${rserver_hostname}" 2>&1)
390391
okay=$?
391-
mdebug " - checkpid('${pid}', '${rserver_hostname}') exit code: ${okay}"
392+
mdebug " - check_pid('${pid}', '${rserver_hostname}') exit code: ${okay}, output='$(printf "%q" "${res[*]}")'"
392393
relay_condition "${res[@]}"
393394
mapfile -t res < <(prune_debug "${res[@]}")
394395

@@ -413,6 +414,7 @@ function make_database_conf {
413414
## Default: /var/lib/rstudio-server
414415
echo "directory=${workdir}/lib"
415416
} > "${workdir}/database.conf"
417+
assert_file_is_not_empty "${workdir}/database.conf"
416418
}
417419

418420
function make_rserver_conf {
@@ -481,6 +483,7 @@ function make_rserver_conf {
481483
## The web port for the RStudio Server
482484
echo "www-port=${port:?}"
483485
} > "${workdir}/rserver.conf"
486+
assert_file_is_not_empty "${workdir}/rserver.conf"
484487

485488
mdebug "make_rserver_conf() ... done"
486489
}
@@ -683,8 +686,9 @@ function rs_process_status {
683686
warn_if_check_pid_needs_ssh "${hostname}"
684687
mapfile -t res < <(check_pid "${pid}" "${rserver_hostname}" 2>&1)
685688
okay=$?
686-
mdebug " - checkpid('${pid}', '${rserver_hostname}') exit code: ${okay}"
689+
mdebug " - check_pid('${pid}', '${rserver_hostname}') exit code: ${okay}, output='$(printf "%q" "${res[*]}")'"
687690
mapfile -t res < <(prune_debug "${res[@]}")
691+
mdebug " - prune_debug(): '$(printf "%q" "${res[*]}")'"
688692
if [[ -n "${res[0]}" ]]; then
689693
pid="${res[0]}"
690694
else
@@ -757,6 +761,7 @@ function make_rsession_envs {
757761
mv "${outfile}.tmp.tmp" "${outfile}"
758762
rm -f "${outfile}.tmp"
759763
mdebug "Created: ${outfile} [$(wc -l "${outfile}" | cut -d ' ' -f 1) variables: $(sed -E 's/(^declare -x |=.*$)//g' "${outfile}" | tr $'\n' ' ' | sed -E 's/ $//' | sed 's/ /, /g')]"
764+
assert_file_is_not_empty "${outfile}"
760765
}
761766

762767
function make_rsession_conf {
@@ -772,6 +777,7 @@ function make_rsession_conf {
772777
## The default R_LIBS_USER folder that the R session will use
773778
echo "r-libs-user=${R_LIBS_USER:?}"
774779
} > "${workdir}/rsession.conf"
780+
assert_file_is_not_empty "${workdir}/rsession.conf"
775781
}
776782

777783

@@ -837,6 +843,7 @@ set -x
837843
838844
exec rsession "\${@}"
839845
END
846+
assert_file_is_not_empty "${workdir}/rsession.sh"
840847

841848
chmod +x "${workdir}/rsession.sh"
842849
}
@@ -1099,7 +1106,9 @@ function launch_rserver {
10991106
assert_dir_exists "${workdir}"
11001107

11011108
hostname > "${workdir}/rserver.hostname"
1109+
assert_file_is_not_empty "${workdir}/rserver.hostname"
11021110
grep -E "www-port=" "$(config_dir)/rserver.conf" | sed 's/www-port=//' > "${workdir}/rserver.port"
1111+
assert_file_is_not_empty "${workdir}/rserver.port"
11031112

11041113
port=$(rserver_port)
11051114
assert_port_free "${port}"
@@ -1114,6 +1123,7 @@ function launch_rserver {
11141123
fi
11151124
rs_pid=$!
11161125
echo "${rs_pid}" > "${pid_file}"
1126+
assert_file_is_not_empty "${pid_file}"
11171127
rs_pid=$(rserver_pid)
11181128
mdebug "RStudio Server started (PID ${rs_pid})"
11191129
}
@@ -1265,6 +1275,7 @@ function launch_rserver_monitor {
12651275
fi
12661276
pid=$!
12671277
echo "${pid}" > "${pid_file}"
1278+
assert_file_is_not_empty "${pid_file}"
12681279

12691280
pid=$(rserver_pid)
12701281
mdebug "rserver monitor started (PID ${pid})"
@@ -1563,10 +1574,10 @@ fi
15631574
## Validate 'port':
15641575
if [[ "${port}" == "random" ]]; then
15651576
port="port4me"
1566-
warn "--port=random is deprecated in favor of --port=port4me (default)"
1577+
error "--port=random is defunct in favor of --port=port4me (default)"
15671578
elif [[ "${port}" == "uid" ]]; then
15681579
port="port4me"
1569-
warn "--port=uid is deprecated in favor of --port=port4me (default)"
1580+
error "--port=uid is defunct in favor of --port=port4me (default)"
15701581
elif [[ "${port}" != "port4me" ]]; then
15711582
assert_port "${port}"
15721583
fi
@@ -1781,7 +1792,7 @@ elif [[ "${action}" == "stop" ]]; then
17811792
lockfile=${workdir}/pid.lock
17821793
## If running, make sure we're stopping from the correct machine
17831794
if [[ -f "${lockfile}" ]] && [[ "$(hostname)" != "$(rserver_hostname)" ]]; then
1784-
error "Stopping the RStudio Server can only be made from the machine ($(rserver_hostname)) where it was started from"
1795+
error "Stopping the RStudio Server can only be made from the machine ($(rserver_hostname)) where it was started from - not from $(hostname)"
17851796
fi
17861797

17871798
## Terminate rsession
@@ -1914,10 +1925,12 @@ elif [[ "${action}" == "start" ]]; then
19141925
else
19151926
mdebug "ssh -o ConnectTimeout=\"$(ssh_timeout)\" -N -R \"${rev_spec}\" \"${rev_hostname}\""
19161927
printf "%s\n%s\n" "${rev_hostname}" "${rev_port}" > "$(ssh_revtunnel_spec_file)"
1928+
assert_file_is_not_empty "$(ssh_revtunnel_spec_file)"
19171929
ssh -o ConnectTimeout="$(ssh_timeout)" -N -R "${rev_spec}" "${rev_hostname}" &
19181930
fi
19191931
ssh_pid=$!
19201932
echo "${ssh_pid}" > "${pid_file}"
1933+
assert_file_is_not_empty "${pid_file}"
19211934
ssh_pid=$(ssh_revtunnel_pid false)
19221935
mdebug "Reverse SSH tunnel started (PID ${ssh_pid})"
19231936
pids+=("${ssh_pid}")

0 commit comments

Comments
 (0)