@@ -87,6 +87,8 @@ async def cull_idle(
87
87
internal_certs_location = "" ,
88
88
cull_admin_users = True ,
89
89
api_page_size = 0 ,
90
+ cull_default_servers = True ,
91
+ cull_named_servers = True ,
90
92
):
91
93
"""Shutdown idle single-user servers
92
94
@@ -234,8 +236,16 @@ async def handle_server(user, server_name, server, max_age, inactive_limit):
234
236
# return False
235
237
# inactive_limit = server['state']['culltime']
236
238
239
+ is_default_server = server_name == ""
240
+ is_named_server = server_name != ""
241
+
237
242
should_cull = (
238
- inactive is not None and inactive .total_seconds () >= inactive_limit
243
+ inactive is not None
244
+ and inactive .total_seconds () >= inactive_limit
245
+ and (
246
+ (cull_default_servers and is_default_server )
247
+ or (cull_named_servers and is_named_server )
248
+ )
239
249
)
240
250
if should_cull :
241
251
app_log .info (
@@ -561,6 +571,26 @@ def main():
561
571
"""
562
572
).strip (),
563
573
)
574
+ define (
575
+ "cull_default_servers" ,
576
+ type = bool ,
577
+ default = True ,
578
+ help = dedent (
579
+ """
580
+ Whether default servers should be culled (only if --cull-default-servers=true).
581
+ """
582
+ ).strip (),
583
+ )
584
+ define (
585
+ "cull_named_servers" ,
586
+ type = bool ,
587
+ default = True ,
588
+ help = dedent (
589
+ """
590
+ Whether named servers should be culled (only if --cull-named-servers=true).
591
+ """
592
+ ).strip (),
593
+ )
564
594
565
595
parse_command_line ()
566
596
if not options .cull_every :
@@ -589,6 +619,8 @@ def main():
589
619
internal_certs_location = options .internal_certs_location ,
590
620
cull_admin_users = options .cull_admin_users ,
591
621
api_page_size = options .api_page_size ,
622
+ cull_default_servers = options .cull_default_servers ,
623
+ cull_named_servers = options .cull_named_servers ,
592
624
)
593
625
# schedule first cull immediately
594
626
# because PeriodicCallback doesn't start until the end of the first interval
0 commit comments