mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Enforce the type of idle culler options
This commit is contained in:
@@ -203,27 +203,22 @@ def update_traefik_api(c, config):
|
||||
c.TraefikTomlProxy.traefik_api_password = config['traefik_api']['password']
|
||||
|
||||
|
||||
def set_cull_idle_service(c, config):
|
||||
def set_cull_idle_service(config):
|
||||
"""
|
||||
Set Idle Culler service
|
||||
"""
|
||||
cull_cmd = [
|
||||
sys.executable, '/srv/src/tljh/cull_idle_servers.py'
|
||||
]
|
||||
if config['services']['cull']['timeout']:
|
||||
cull_cmd.append('--timeout=%s' % config['services']['cull']['timeout'])
|
||||
cull_config = config['services']['cull']
|
||||
print()
|
||||
|
||||
if config['services']['cull']['every']:
|
||||
cull_cmd.append('--cull-every=%s' % config['services']['cull']['every'])
|
||||
|
||||
if config['services']['cull']['concurrency']:
|
||||
cull_cmd.append('--concurrency=%s' % config['services']['cull']['concurrency'])
|
||||
|
||||
if config['services']['cull']['users']:
|
||||
cull_cmd.append('--cull-users')
|
||||
|
||||
if config['services']['cull']['max_age']:
|
||||
cull_cmd.append('--max-age=%s' % config['services']['cull']['max_age'])
|
||||
cull_cmd += ['--timeout=%d' % cull_config['timeout']]
|
||||
cull_cmd += ['--cull-every=%d' % cull_config['every']]
|
||||
cull_cmd += ['--concurrency=%d' % cull_config['concurrency']]
|
||||
cull_cmd += ['--max-age=%d' % cull_config['max_age']]
|
||||
if cull_config['users']:
|
||||
cull_cmd += ['--cull-users']
|
||||
|
||||
cull_service = {
|
||||
'name': 'cull-idle',
|
||||
@@ -237,7 +232,7 @@ def set_cull_idle_service(c, config):
|
||||
def update_services(c, config):
|
||||
c.JupyterHub.services = []
|
||||
if config['services']['cull']['enabled']:
|
||||
c.JupyterHub.services.append(set_cull_idle_service(c, config))
|
||||
c.JupyterHub.services.append(set_cull_idle_service(config))
|
||||
|
||||
|
||||
def _merge_dictionaries(a, b, path=None, update=True):
|
||||
|
||||
@@ -290,16 +290,16 @@ if __name__ == '__main__':
|
||||
default=os.environ.get('JUPYTERHUB_API_URL'),
|
||||
help="The JupyterHub API URL",
|
||||
)
|
||||
define('timeout', default=600, help="The idle timeout (in seconds)")
|
||||
define('cull_every', default=0,
|
||||
define('timeout', type=int, default=600, help="The idle timeout (in seconds)")
|
||||
define('cull_every', type=int, default=0,
|
||||
help="The interval (in seconds) for checking for idle servers to cull")
|
||||
define('max_age', default=0,
|
||||
define('max_age', type=int, default=0,
|
||||
help="The maximum age (in seconds) of servers that should be culled even if they are active")
|
||||
define('cull_users', default=False,
|
||||
define('cull_users', type=bool, default=False,
|
||||
help="""Cull users in addition to servers.
|
||||
This is for use in temporary-user cases such as tmpnb.""",
|
||||
)
|
||||
define('concurrency', default=10,
|
||||
define('concurrency', type=int, default=10,
|
||||
help="""Limit the number of concurrent requests made to the Hub.
|
||||
|
||||
Deleting a lot of users at the same time can slow down the Hub,
|
||||
|
||||
Reference in New Issue
Block a user