Skip to content

Commit 1506298

Browse files
Add support for RSC_RSESSION_TIMEOUT_SUSPEND [#100]
1 parent 7aeece9 commit 1506298

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## Version (development version)
22

3-
* ...
3+
### New Features
4+
5+
* Add environment variable `RSC_RSESSION_TIMEOUT_SUSPEND` to control
6+
whether a timed out R session should be suspended to disk. If `1`
7+
(default), it will be suspended to disk, otherwise not.
48

59

610
## Version 0.16.2 [2024-08-21]

bin/rsc

Lines changed: 25 additions & 3 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.2
66+
### Version: 0.16.2-9001
6767
### Copyright: Henrik Bengtsson (2022-2024) and Harry Putnam (2022)
6868
### License: ISC
6969

@@ -723,7 +723,6 @@ function rs_process_status {
723723

724724
function rsession_timeout {
725725
local timeout
726-
local bfr
727726
timeout=${RSC_RSESSION_TIMEOUT}
728727

729728
if [[ -z "${timeout}" ]]; then
@@ -739,6 +738,23 @@ function rsession_timeout {
739738
}
740739

741740

741+
function rsession_timeout_suspend {
742+
local value
743+
value=${RSC_RSESSION_TIMEOUT_SUSPEND}
744+
745+
if [[ -z "${value}" ]]; then
746+
## The default is to suspend
747+
value=1
748+
fi
749+
750+
mdebug "rsession timeout suspend: ${value}"
751+
assert_integer "${value}"
752+
RSC_RSESSION_TIMEOUT_SUSPEND="${value}"
753+
export RSC_RSESSION_TIMEOUT_SUSPEND
754+
echo "${value}"
755+
}
756+
757+
742758
function make_rsession_envs {
743759
local workdir
744760
local pattern
@@ -777,6 +793,12 @@ function make_rsession_conf {
777793
## Number of minutes before a session times out, at which point
778794
## the session will either suspend
779795
echo "session-timeout-minutes=$(rsession_timeout)"
796+
797+
## Indicates whether or not to suspend the session after the
798+
## timeout has elapsed. Setting this to false will cause the
799+
## session to quit instead of suspending to disk when the session
800+
## times out. (Type: bool; Default: 1)
801+
echo "session-timeout-suspend=$(rsession_timeout_suspend)"
780802

781803
## The default R_LIBS_USER folder that the R session will use
782804
echo "r-libs-user=${R_LIBS_USER:?}"
@@ -1713,7 +1735,7 @@ if [[ "${action}" == "config" ]]; then
17131735
echo "RSTUDIO_CONFIG_HOME: ${RSTUDIO_CONFIG_HOME:-<not set>}"
17141736
workdir=$(rstudio_config_home)
17151737
echo "RStudio config home: ${workdir}"
1716-
file=${workdir}/rstudio-prefs.json
1738+
file=${workdir}/rstudio-prefs.json
17171739
echo "RStudio user preferences: ${file} [$(file_info "${file}")]"
17181740
if $full && [[ -f "${file}" ]]; then
17191741
cat "${file}"

0 commit comments

Comments
 (0)