From 9ef0b7be167f6cfe82ec5da0d5e58e441ed1fac1 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 12 Apr 2024 14:54:28 +0100 Subject: [PATCH 1/4] Add backend flag to keep alive --- jhub_apps/__about__.py | 2 +- jhub_apps/spawner/spawner_creation.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jhub_apps/__about__.py b/jhub_apps/__about__.py index b414021a..a1839622 100644 --- a/jhub_apps/__about__.py +++ b/jhub_apps/__about__.py @@ -1 +1 @@ -__version__ = "2024.4.1rc7" +__version__ = "2024.4.1rc8" diff --git a/jhub_apps/spawner/spawner_creation.py b/jhub_apps/spawner/spawner_creation.py index 0c01ec73..eff9b686 100644 --- a/jhub_apps/spawner/spawner_creation.py +++ b/jhub_apps/spawner/spawner_creation.py @@ -102,6 +102,17 @@ async def start(self): python_exec=self.config.JAppsConfig.python_exec, authtype=auth_type, ) + # Only for non-JupyterLab apps + if self.user_options.get("keep_alive"): + logger.info( + "Flag set to force keep alive, will not be deleted by idle culler", + app=self.user_options.get("display_name"), + framework=self.user_options.get("framework") + ) + self.cmd.append("--force-alive") + else: + self.cmd.append("--no-force-alive") + if framework == Framework.jupyterlab.value: self.cmd = [ self.config.JAppsConfig.python_exec, From 8f4abe73b5f23492f72b074b19218836aa911f5d Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 12 Apr 2024 15:02:44 +0100 Subject: [PATCH 2/4] remove default --no-force-alive --- jhub_apps/spawner/command.py | 1 - 1 file changed, 1 deletion(-) diff --git a/jhub_apps/spawner/command.py b/jhub_apps/spawner/command.py index 283a5bc6..bd7a2700 100644 --- a/jhub_apps/spawner/command.py +++ b/jhub_apps/spawner/command.py @@ -55,7 +55,6 @@ def get_substituted_args(self, **kwargs): "-m", "jhsingle_native_proxy.main", TString("--authtype=$authtype"), - "--no-force-alive", ] ) From 94c55f9772eb0bc327da6c4e5a12bd08f48d8a7f Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 12 Apr 2024 15:20:08 +0100 Subject: [PATCH 3/4] add keep_alive to model --- jhub_apps/service/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/jhub_apps/service/models.py b/jhub_apps/service/models.py index 2a91a3c7..ecc00217 100644 --- a/jhub_apps/service/models.py +++ b/jhub_apps/service/models.py @@ -63,6 +63,7 @@ class UserOptions(BaseModel): profile: typing.Optional[str] = str() # Make app available to public (unauthenticated Hub users) public: typing.Optional[bool] = False + keep_alive: typing.Optional[bool] = False class ServerCreation(BaseModel): From 53592a57da795ba665ccf7ccb8decbfca10edbbc Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 12 Apr 2024 15:22:43 +0100 Subject: [PATCH 4/4] add a note aboute keep_alive --- jhub_apps/service/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jhub_apps/service/models.py b/jhub_apps/service/models.py index ecc00217..cd4efdf5 100644 --- a/jhub_apps/service/models.py +++ b/jhub_apps/service/models.py @@ -63,6 +63,8 @@ class UserOptions(BaseModel): profile: typing.Optional[str] = str() # Make app available to public (unauthenticated Hub users) public: typing.Optional[bool] = False + # Keep app alive, even when there is no activity + # So that it's not killed by idle culler keep_alive: typing.Optional[bool] = False