Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backend flag to keep alive #231

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jhub_apps/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2024.4.1rc7"
__version__ = "2024.4.1rc8"
3 changes: 3 additions & 0 deletions jhub_apps/service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ 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


class ServerCreation(BaseModel):
Expand Down
1 change: 0 additions & 1 deletion jhub_apps/spawner/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def get_substituted_args(self, **kwargs):
"-m",
"jhsingle_native_proxy.main",
TString("--authtype=$authtype"),
"--no-force-alive",
]
)

Expand Down
11 changes: 11 additions & 0 deletions jhub_apps/spawner/spawner_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading