Skip to content

Commit 739e337

Browse files
Merge branch 'release/0.16.0'
2 parents b5df9ba + 2522dcd commit 739e337

File tree

4 files changed

+67
-39
lines changed

4 files changed

+67
-39
lines changed

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## Version 0.16.0 [2024-02-01]
2+
3+
### New Features
4+
5+
* Now `rsc start` asserts that there are no stray 'rsession'
6+
processes running.
7+
8+
* Now `rsc status` warns about stray 'rsession' processes.
9+
10+
111
## Version 0.15.1 [2024-01-25]
212

313
### 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.1.tar.gz
337-
$ tar xf 0.15.1.tar.gz
338-
$ PATH=/path/to/softwarerstudio-server-controller-0.15.1/bin:$PATH
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
339339
$ export PATH
340340
$ rsc --version
341-
0.15.1
341+
0.16.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.15.1
349+
rsc: 0.16.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/output.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,6 @@ function mdebug0 {
3535
} 1>&2
3636
}
3737

38-
function merror {
39-
local info
40-
{
41-
info="$(basename "$0") $(version)"
42-
[[ -n $info ]] && info=" [$info]"
43-
_tput setaf 1 ## red
44-
echo "ERROR: $*$info"
45-
_tput sgr0 ## reset
46-
} 1>&2
47-
_exit 1
48-
}
49-
50-
function mwarn {
51-
{
52-
_tput setaf 3 ## yellow
53-
echo "WARNING: $*"
54-
_tput sgr0 ## reset
55-
} 1>&2
56-
}
57-
5838
function minfo {
5939
if ! $verbose; then
6040
return

bin/rsc

Lines changed: 52 additions & 14 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.1
66+
### Version: 0.16.0
6767
### Copyright: Henrik Bengtsson (2022-2024) and Harry Putnam (2022)
6868
### License: ISC
6969

@@ -518,7 +518,7 @@ function warn_if_check_pid_needs_ssh {
518518
local hostname
519519
hostname=${1:-?}
520520
if ${ssh} && [[ "${hostname}" != "$(hostname)" ]]; then
521-
mwarn "Needs to SSH to ${hostname} to check whether process ${pid} is still alive. If you don't have SSH key authentication set up, you will be asked to enter your account password below."
521+
warn "Needs to SSH to ${hostname} to check whether process ${pid} is still alive. If you don't have SSH key authentication set up, you will be asked to enter your account password below."
522522
fi
523523
}
524524

@@ -899,6 +899,30 @@ function rsession_status {
899899
rs_process_status "$(rsession_pid true)" "$(rserver_hostname)"
900900
}
901901

902+
function assert_no_rsession {
903+
local action
904+
local -i pid
905+
local -i pids
906+
local call
907+
local msg
908+
local workdir
909+
910+
action=${1:-error}
911+
workdir=$(config_dir)
912+
913+
mdebug "assert_no_rsession(action='$1') ..."
914+
915+
if [[ $(rsession_status) != "not running" ]]; then
916+
if [[ $(rserver_status) == "not running" ]]; then
917+
error "Detected stray 'rsession' processes. Use 'rsc stop' to terminate them"
918+
else
919+
error "[INTERNAL] Detected unexpected 'rsession' processes"
920+
fi
921+
fi
922+
923+
mdebug "assert_no_rsession(action='$1') ... done"
924+
}
925+
902926

903927
# -------------------------------------------------------------------------
904928
# rserver utilities
@@ -1204,7 +1228,7 @@ function rserver_monitor {
12041228
if [[ $(rsession_status) == "not running" ]]; then
12051229
state="wait_and_terminate_rserver"
12061230
endtime=$((SECONDS + (60 * $(rserver_timeout)) ))
1207-
mwarn "The RStudio Server (PID $(rserver_pid)) will time out in $(rserver_timeout) minutes on $(date --rfc-3339=seconds --date="+$(rserver_timeout) minutes"), unless a new R session is started"
1231+
warn "The RStudio Server (PID $(rserver_pid)) will time out in $(rserver_timeout) minutes on $(date --rfc-3339=seconds --date="+$(rserver_timeout) minutes"), unless a new R session is started"
12081232
fi
12091233
elif [[ "${state}" == "wait_and_terminate_rserver" ]]; then
12101234
## Reset or check countdown watch?
@@ -1214,7 +1238,7 @@ function rserver_monitor {
12141238
else
12151239
mdebug "rserver_monitor(): countdown clock: $((endtime - SECONDS)) seconds"
12161240
if [[ ${SECONDS} -gt ${endtime} ]]; then
1217-
mwarn "The RStudio Server (PID $(rserver_pid)) was shut down on $(date --rfc-3339=seconds) after $(rserver_timeout) minutes without an active R session"
1241+
warn "The RStudio Server (PID $(rserver_pid)) was shut down on $(date --rfc-3339=seconds) after $(rserver_timeout) minutes without an active R session"
12181242
terminate_rserver
12191243
terminate_ssh_revtunnel
12201244
fi
@@ -1483,7 +1507,7 @@ while [[ $# -gt 0 ]]; do
14831507
value=${1//--[[:alpha:]]*=}
14841508
mdebug "Key-value option '$1' parsed to key='${key}', value='${value}'"
14851509
if [[ -z ${value} ]]; then
1486-
merror "Option '--${key}' must not be empty"
1510+
error "Option '--${key}' must not be empty"
14871511
fi
14881512
if [[ "${key}" == "port" ]]; then
14891513
port=${value}
@@ -1504,7 +1528,7 @@ while [[ $# -gt 0 ]]; do
15041528
[[ -z "${value}" ]] && error "Option '--revtunnel' must not be empty"
15051529
mapfile -t revtunnel < <(parse_revtunnel "${value}")
15061530
else
1507-
merror "Unknown option: $1"
1531+
error "Unknown option: $1"
15081532
fi
15091533
## Additional options to be appended (rarely needed)
15101534
else
@@ -1539,10 +1563,10 @@ fi
15391563
## Validate 'port':
15401564
if [[ "${port}" == "random" ]]; then
15411565
port="port4me"
1542-
mwarn "--port=random is deprecated in favor of --port=port4me (default)"
1566+
warn "--port=random is deprecated in favor of --port=port4me (default)"
15431567
elif [[ "${port}" == "uid" ]]; then
15441568
port="port4me"
1545-
mwarn "--port=uid is deprecated in favor of --port=port4me (default)"
1569+
warn "--port=uid is deprecated in favor of --port=port4me (default)"
15461570
elif [[ "${port}" != "port4me" ]]; then
15471571
assert_port "${port}"
15481572
fi
@@ -1707,8 +1731,10 @@ elif [[ "${action}" == "log" ]]; then
17071731
elif [[ "${action}" == "status" ]]; then
17081732
mdebug "rsc status ..."
17091733
if [[ -z ${field} ]]; then
1710-
status="rserver: $(rserver_status)\n"
1711-
status="${status}rsession: $(rsession_status)\n"
1734+
status_rserver=$(rserver_status)
1735+
status_rsession=$(rsession_status)
1736+
status="rserver: ${status_rserver}\n"
1737+
status="${status}rsession: ${status_rsession}\n"
17121738
status="${status}rserver monitor: $(rserver_monitor_status)\n"
17131739
status="${status}SSH reverse tunnel (optional): $(ssh_revtunnel_status)"
17141740

@@ -1726,6 +1752,11 @@ elif [[ "${action}" == "status" ]]; then
17261752
echo "lock file: does not exist"
17271753
fi
17281754

1755+
## Warn about stray 'rsession' processes
1756+
if [[ ${status_rserver} == "not running" ]] && [[ ${status_rsession} != "not running" ]]; then
1757+
warn "Detected stray 'rsession' processes. These cannot be recovered. Use 'rsc stop' to terminate them"
1758+
fi
1759+
17291760
## Display info on how to reconnect?
17301761
if $full; then
17311762
res=$(rs_process_status "$(rserver_pid true)" "$(rserver_hostname)")
@@ -1799,6 +1830,11 @@ elif [[ "${action}" == "start" ]]; then
17991830
assert_executable rserver
18001831
assert_executable rsession
18011832
mdebug "Assert sufficient software setup ... done"
1833+
1834+
## Assert that there is no rserver and rsession processes
1835+
## created by rsc currently running
1836+
assert_no_rserver error
1837+
assert_no_rsession error
18021838

18031839
if [[ "${port}" != "port4me" ]]; then
18041840
assert_port_free "${port}"
@@ -1825,8 +1861,10 @@ elif [[ "${action}" == "start" ]]; then
18251861

18261862
mdebug "PID for rsc (this process): $$"
18271863

1828-
## Assert that there is no rserver process created by rsc running
1829-
assert_no_rserver
1864+
## Assert that there is no rserver and rsession processes
1865+
## created by rsc currently running (one more time, just in case)
1866+
assert_no_rserver error
1867+
assert_no_rsession error
18301868

18311869
## Shutdown nicely
18321870
mdebug "Registering 'trap shutdown EXIT', which perform cleanups"
@@ -1835,7 +1873,7 @@ elif [[ "${action}" == "start" ]]; then
18351873

18361874
rdata=$(find_RData)
18371875
if [[ -f "${rdata}" ]]; then
1838-
mwarn "Detected ${rdata} [$(stat -c "%s" "${rdata}") bytes]. It will be loaded by R during startup. If this file is very large, R might fail to launch."
1876+
warn "Detected ${rdata} [$(stat -c "%s" "${rdata}") bytes]. It will be loaded by R during startup. If this file is very large, R might fail to launch."
18391877
fi
18401878

18411879
launch_rserver
@@ -1901,7 +1939,7 @@ elif [[ "${action}" == "start" ]]; then
19011939

19021940
message "Any R session started times out after being idle for $(rsession_timeout) minutes."
19031941

1904-
mwarn "You now have $(rserver_timeout) minutes, until $(date --rfc-3339=seconds --date="+$(rserver_timeout) minutes"), to connect and log in to the RStudio Server before everything times out."
1942+
warn "You now have $(rserver_timeout) minutes, until $(date --rfc-3339=seconds --date="+$(rserver_timeout) minutes"), to connect and log in to the RStudio Server before everything times out."
19051943

19061944
if ${RSC_PASSWORD_ECHO:-false}; then
19071945
message "Your password for this RStudio Server instance is: ${blue}${RSC_PASSWORD}${undo}"

0 commit comments

Comments
 (0)