63
63
# ## rsc config --full
64
64
# ## rsc log
65
65
# ##
66
- # ## Version: 0.14.4
66
+ # ## Version: 0.15.0
67
67
# ## Copyright: Henrik Bengtsson (2022-2024) and Harry Putnam (2022)
68
68
# ## License: ISC
69
69
@@ -315,7 +315,7 @@ function remove_stray_pid_file {
315
315
local -i pid
316
316
local rserver_hostname
317
317
local what
318
- local res
318
+ local -a res
319
319
local -i okay
320
320
321
321
what=${1:? }
@@ -365,13 +365,13 @@ function remove_stray_pid_file {
365
365
366
366
# # If this process is not running, remove the PID file
367
367
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 )
369
369
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
375
375
rm " ${pid_file} "
376
376
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."
377
377
return 0
@@ -530,8 +530,8 @@ function check_pid {
530
530
# shellcheck disable=SC2029
531
531
res=$( ssh -o ConnectTimeout=" $( ssh_timeout) " " ${hostname} " " [[ -d '/proc/${pid} ' ]] && echo true || echo false" 2>&1 )
532
532
okay=$?
533
- mdebug " - Result: ${res} "
534
533
mdebug " - Exit code: ${okay} "
534
+ mdebug " - Result: ${res} "
535
535
if [[ ${okay} -ne 0 ]]; then
536
536
# # Remove empty leading lines
537
537
res=$( sed -e ' /./,$!d' <<< " ${res}" )
@@ -616,12 +616,16 @@ function find_login_host_via_who {
616
616
function find_login_host {
617
617
local host
618
618
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'
621
624
if [[ -z " ${host} " ]]; then
622
625
host=$( find_login_host_via_who)
623
626
fi
624
627
628
+ # # 3. Fall back to template instructions
625
629
if [[ -z " ${host} " ]]; then
626
630
host=" <login-machine>"
627
631
fi
@@ -632,6 +636,7 @@ function find_login_host {
632
636
host=$( echo " ${full} " | cut -d ' ' -f 1)
633
637
fi
634
638
fi
639
+
635
640
echo " ${host} "
636
641
}
637
642
@@ -645,7 +650,8 @@ function rs_process_status {
645
650
local pid_info
646
651
local pid_stats
647
652
local tmp
648
- local res
653
+ local -i okay
654
+ local -a res
649
655
pid=${1}
650
656
hostname=${2}
651
657
@@ -654,13 +660,16 @@ function rs_process_status {
654
660
# # Check if PID is still active?
655
661
if [[ ${pid} -ne 0 ]]; then
656
662
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 )
658
664
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
662
672
fi
663
-
664
673
665
674
if [[ ${pid} -ne 0 ]]; then
666
675
pid_info=" PID ${pid} "
@@ -687,7 +696,7 @@ function rsession_timeout {
687
696
local timeout
688
697
local bfr
689
698
timeout=${RSC_RSESSION_TIMEOUT}
690
-
699
+
691
700
if [[ -z " ${timeout} " ]]; then
692
701
# # The default is 120 minutes (2 hours)
693
702
timeout=120
@@ -1054,7 +1063,7 @@ function launch_rserver {
1054
1063
mdebug " rserver --config-file=\" ${workdir} /rserver.conf\" &"
1055
1064
if $dryrun ; then
1056
1065
echo " DRYRUN: rserver --config-file=\" ${workdir} /rserver.conf\" "
1057
- sleep 60 &
1066
+ sleep 10 &
1058
1067
else
1059
1068
rserver --config-file=" ${workdir} /rserver.conf" &
1060
1069
fi
@@ -1205,7 +1214,7 @@ function launch_rserver_monitor {
1205
1214
pid_file=$( rserver_monitor_pid_file)
1206
1215
if $dryrun ; then
1207
1216
echo " DRYRUN: rserver_monitor launched"
1208
- sleep 60 &
1217
+ sleep 10 &
1209
1218
else
1210
1219
rserver_monitor &
1211
1220
fi
@@ -1405,7 +1414,6 @@ ssh=${RSC_SSH:-true}
1405
1414
# # behavior prevents R from seeing, for instance, environment variables
1406
1415
# # set by a job scheduler.
1407
1416
rsession_inherit_env_pattern=${RSC_ENV_PATTERN:- " ^.+$" }
1408
-
1409
1417
1410
1418
# Parse command-line options
1411
1419
while [[ $# -gt 0 ]]; do
@@ -1540,6 +1548,15 @@ mdebug "auth: ${auth}"
1540
1548
mdebug " RSC_AUTH_ARG_2: ${RSC_AUTH_ARG_2} "
1541
1549
mdebug " revtunnel: [n=${# revtunnel[@]} ] ${revtunnel[*]} "
1542
1550
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>} "
1543
1560
mdebug " args: [n=${# args[@]} ] ${args[*]} "
1544
1561
1545
1562
# # Enable terminal colors, if supported
@@ -1558,6 +1575,23 @@ fi
1558
1575
if [[ " ${action} " == " config" ]]; then
1559
1576
files=()
1560
1577
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
1561
1595
echo " RStudio Server Controller Storage:"
1562
1596
echo " XDG_CONFIG_HOME=${XDG_CONFIG_HOME:- <not set>} "
1563
1597
@@ -1802,7 +1836,7 @@ elif [[ "${action}" == "start" ]]; then
1802
1836
pid_file=$( ssh_revtunnel_pid_file)
1803
1837
if $dryrun ; then
1804
1838
echo " DRYRUN: ssh -o ConnectTimeout=\" $( ssh_timeout) \" -N -R \" ${rev_spec} \" \" ${rev_hostname} \" "
1805
- sleep 60 &
1839
+ sleep 10 &
1806
1840
else
1807
1841
mdebug " ssh -o ConnectTimeout=\" $( ssh_timeout) \" -N -R \" ${rev_spec} \" \" ${rev_hostname} \" "
1808
1842
printf " %s\n%s\n" " ${rev_hostname} " " ${rev_port} " > " $( ssh_revtunnel_spec_file) "
0 commit comments