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']
|
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
|
Set Idle Culler service
|
||||||
"""
|
"""
|
||||||
cull_cmd = [
|
cull_cmd = [
|
||||||
sys.executable, '/srv/src/tljh/cull_idle_servers.py'
|
sys.executable, '/srv/src/tljh/cull_idle_servers.py'
|
||||||
]
|
]
|
||||||
if config['services']['cull']['timeout']:
|
cull_config = config['services']['cull']
|
||||||
cull_cmd.append('--timeout=%s' % config['services']['cull']['timeout'])
|
print()
|
||||||
|
|
||||||
if config['services']['cull']['every']:
|
cull_cmd += ['--timeout=%d' % cull_config['timeout']]
|
||||||
cull_cmd.append('--cull-every=%s' % config['services']['cull']['every'])
|
cull_cmd += ['--cull-every=%d' % cull_config['every']]
|
||||||
|
cull_cmd += ['--concurrency=%d' % cull_config['concurrency']]
|
||||||
if config['services']['cull']['concurrency']:
|
cull_cmd += ['--max-age=%d' % cull_config['max_age']]
|
||||||
cull_cmd.append('--concurrency=%s' % config['services']['cull']['concurrency'])
|
if cull_config['users']:
|
||||||
|
cull_cmd += ['--cull-users']
|
||||||
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_service = {
|
cull_service = {
|
||||||
'name': 'cull-idle',
|
'name': 'cull-idle',
|
||||||
@@ -237,7 +232,7 @@ def set_cull_idle_service(c, config):
|
|||||||
def update_services(c, config):
|
def update_services(c, config):
|
||||||
c.JupyterHub.services = []
|
c.JupyterHub.services = []
|
||||||
if config['services']['cull']['enabled']:
|
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):
|
def _merge_dictionaries(a, b, path=None, update=True):
|
||||||
|
|||||||
@@ -290,16 +290,16 @@ if __name__ == '__main__':
|
|||||||
default=os.environ.get('JUPYTERHUB_API_URL'),
|
default=os.environ.get('JUPYTERHUB_API_URL'),
|
||||||
help="The JupyterHub API URL",
|
help="The JupyterHub API URL",
|
||||||
)
|
)
|
||||||
define('timeout', default=600, help="The idle timeout (in seconds)")
|
define('timeout', type=int, default=600, help="The idle timeout (in seconds)")
|
||||||
define('cull_every', default=0,
|
define('cull_every', type=int, default=0,
|
||||||
help="The interval (in seconds) for checking for idle servers to cull")
|
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")
|
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.
|
help="""Cull users in addition to servers.
|
||||||
This is for use in temporary-user cases such as tmpnb.""",
|
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.
|
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,
|
Deleting a lot of users at the same time can slow down the Hub,
|
||||||
|
|||||||
Reference in New Issue
Block a user