From d1aaf872dc1f2a309ed4dd66713328228204dcc6 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 12 Apr 2024 15:55:35 +0100 Subject: [PATCH 1/2] add options to configure keep alive from env vars --- jhub_apps/spawner/spawner_creation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jhub_apps/spawner/spawner_creation.py b/jhub_apps/spawner/spawner_creation.py index eff9b686..a2a53928 100644 --- a/jhub_apps/spawner/spawner_creation.py +++ b/jhub_apps/spawner/spawner_creation.py @@ -102,8 +102,9 @@ async def start(self): python_exec=self.config.JAppsConfig.python_exec, authtype=auth_type, ) + env = self.user_options.get("env", {}) # Only for non-JupyterLab apps - if self.user_options.get("keep_alive"): + if self.user_options.get("keep_alive") or env.get("JH_APPS_KEEP_ALIVE"): logger.info( "Flag set to force keep alive, will not be deleted by idle culler", app=self.user_options.get("display_name"), From cee5a1feb8ddede03c4bf833f59cf8b5548c65ff Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 12 Apr 2024 16:00:15 +0100 Subject: [PATCH 2/2] check env before accessing it --- jhub_apps/spawner/spawner_creation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jhub_apps/spawner/spawner_creation.py b/jhub_apps/spawner/spawner_creation.py index a2a53928..9d3bc4cd 100644 --- a/jhub_apps/spawner/spawner_creation.py +++ b/jhub_apps/spawner/spawner_creation.py @@ -104,7 +104,7 @@ async def start(self): ) env = self.user_options.get("env", {}) # Only for non-JupyterLab apps - if self.user_options.get("keep_alive") or env.get("JH_APPS_KEEP_ALIVE"): + if self.user_options.get("keep_alive") or (env and env.get("JH_APPS_KEEP_ALIVE")): logger.info( "Flag set to force keep alive, will not be deleted by idle culler", app=self.user_options.get("display_name"),