63
63
# ## rsc config --full
64
64
# ## rsc log
65
65
# ##
66
- # ## Version: 0.16.0
66
+ # ## Version: 0.16.1
67
67
# ## Copyright: Henrik Bengtsson (2022-2024) and Harry Putnam (2022)
68
68
# ## License: ISC
69
69
@@ -284,6 +284,7 @@ function acquire_lock_file {
284
284
error " ${msg} "
285
285
fi
286
286
echo " ${PPID} " > " ${lockfile} "
287
+ assert_file_is_not_empty " ${lockfile} "
287
288
}
288
289
289
290
function remove_lock_file {
@@ -388,7 +389,7 @@ function remove_stray_pid_file {
388
389
warn_if_check_pid_needs_ssh " ${rserver_hostname} "
389
390
mapfile -t res < <( check_pid " ${pid} " " ${rserver_hostname} " 2>&1 )
390
391
okay=$?
391
- mdebug " - checkpid ('${pid} ', '${rserver_hostname} ') exit code: ${okay} "
392
+ mdebug " - check_pid ('${pid} ', '${rserver_hostname} ') exit code: ${okay} , output=' $( printf " %q " " ${res[*]} " ) ' "
392
393
relay_condition " ${res[@]} "
393
394
mapfile -t res < <( prune_debug " ${res[@]} " )
394
395
@@ -413,6 +414,7 @@ function make_database_conf {
413
414
# # Default: /var/lib/rstudio-server
414
415
echo " directory=${workdir} /lib"
415
416
} > " ${workdir} /database.conf"
417
+ assert_file_is_not_empty " ${workdir} /database.conf"
416
418
}
417
419
418
420
function make_rserver_conf {
@@ -481,6 +483,7 @@ function make_rserver_conf {
481
483
# # The web port for the RStudio Server
482
484
echo " www-port=${port:? } "
483
485
} > " ${workdir} /rserver.conf"
486
+ assert_file_is_not_empty " ${workdir} /rserver.conf"
484
487
485
488
mdebug " make_rserver_conf() ... done"
486
489
}
@@ -683,8 +686,9 @@ function rs_process_status {
683
686
warn_if_check_pid_needs_ssh " ${hostname} "
684
687
mapfile -t res < <( check_pid " ${pid} " " ${rserver_hostname} " 2>&1 )
685
688
okay=$?
686
- mdebug " - checkpid ('${pid} ', '${rserver_hostname} ') exit code: ${okay} "
689
+ mdebug " - check_pid ('${pid} ', '${rserver_hostname} ') exit code: ${okay} , output=' $( printf " %q " " ${res[*]} " ) ' "
687
690
mapfile -t res < <( prune_debug " ${res[@]} " )
691
+ mdebug " - prune_debug(): '$( printf " %q" " ${res[*]} " ) '"
688
692
if [[ -n " ${res[0]} " ]]; then
689
693
pid=" ${res[0]} "
690
694
else
@@ -757,6 +761,7 @@ function make_rsession_envs {
757
761
mv " ${outfile} .tmp.tmp" " ${outfile} "
758
762
rm -f " ${outfile} .tmp"
759
763
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} "
760
765
}
761
766
762
767
function make_rsession_conf {
@@ -772,6 +777,7 @@ function make_rsession_conf {
772
777
# # The default R_LIBS_USER folder that the R session will use
773
778
echo " r-libs-user=${R_LIBS_USER:? } "
774
779
} > " ${workdir} /rsession.conf"
780
+ assert_file_is_not_empty " ${workdir} /rsession.conf"
775
781
}
776
782
777
783
@@ -837,6 +843,7 @@ set -x
837
843
838
844
exec rsession "\$ {@}"
839
845
END
846
+ assert_file_is_not_empty " ${workdir} /rsession.sh"
840
847
841
848
chmod +x " ${workdir} /rsession.sh"
842
849
}
@@ -1099,7 +1106,9 @@ function launch_rserver {
1099
1106
assert_dir_exists " ${workdir} "
1100
1107
1101
1108
hostname > " ${workdir} /rserver.hostname"
1109
+ assert_file_is_not_empty " ${workdir} /rserver.hostname"
1102
1110
grep -E " www-port=" " $( config_dir) /rserver.conf" | sed ' s/www-port=//' > " ${workdir} /rserver.port"
1111
+ assert_file_is_not_empty " ${workdir} /rserver.port"
1103
1112
1104
1113
port=$( rserver_port)
1105
1114
assert_port_free " ${port} "
@@ -1114,6 +1123,7 @@ function launch_rserver {
1114
1123
fi
1115
1124
rs_pid=$!
1116
1125
echo " ${rs_pid} " > " ${pid_file} "
1126
+ assert_file_is_not_empty " ${pid_file} "
1117
1127
rs_pid=$( rserver_pid)
1118
1128
mdebug " RStudio Server started (PID ${rs_pid} )"
1119
1129
}
@@ -1265,6 +1275,7 @@ function launch_rserver_monitor {
1265
1275
fi
1266
1276
pid=$!
1267
1277
echo " ${pid} " > " ${pid_file} "
1278
+ assert_file_is_not_empty " ${pid_file} "
1268
1279
1269
1280
pid=$( rserver_pid)
1270
1281
mdebug " rserver monitor started (PID ${pid} )"
@@ -1563,10 +1574,10 @@ fi
1563
1574
# # Validate 'port':
1564
1575
if [[ " ${port} " == " random" ]]; then
1565
1576
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)"
1567
1578
elif [[ " ${port} " == " uid" ]]; then
1568
1579
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)"
1570
1581
elif [[ " ${port} " != " port4me" ]]; then
1571
1582
assert_port " ${port} "
1572
1583
fi
@@ -1781,7 +1792,7 @@ elif [[ "${action}" == "stop" ]]; then
1781
1792
lockfile=${workdir} /pid.lock
1782
1793
# # If running, make sure we're stopping from the correct machine
1783
1794
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 ) "
1785
1796
fi
1786
1797
1787
1798
# # Terminate rsession
@@ -1914,10 +1925,12 @@ elif [[ "${action}" == "start" ]]; then
1914
1925
else
1915
1926
mdebug " ssh -o ConnectTimeout=\" $( ssh_timeout) \" -N -R \" ${rev_spec} \" \" ${rev_hostname} \" "
1916
1927
printf " %s\n%s\n" " ${rev_hostname} " " ${rev_port} " > " $( ssh_revtunnel_spec_file) "
1928
+ assert_file_is_not_empty " $( ssh_revtunnel_spec_file) "
1917
1929
ssh -o ConnectTimeout=" $( ssh_timeout) " -N -R " ${rev_spec} " " ${rev_hostname} " &
1918
1930
fi
1919
1931
ssh_pid=$!
1920
1932
echo " ${ssh_pid} " > " ${pid_file} "
1933
+ assert_file_is_not_empty " ${pid_file} "
1921
1934
ssh_pid=$( ssh_revtunnel_pid false)
1922
1935
mdebug " Reverse SSH tunnel started (PID ${ssh_pid} )"
1923
1936
pids+=(" ${ssh_pid} " )
0 commit comments