From ac2590c679cd94ea2cead6e9fd1b6947122638bd Mon Sep 17 00:00:00 2001 From: Daisuke Taniwaki Date: Wed, 6 Jun 2018 19:00:34 +0900 Subject: [PATCH] Add active_user_window configuration --- jupyterhub/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jupyterhub/app.py b/jupyterhub/app.py index 8c23a2c7..3f0215a4 100644 --- a/jupyterhub/app.py +++ b/jupyterhub/app.py @@ -274,6 +274,9 @@ class JupyterHub(Application): service_check_interval = Integer(60, help="Interval (in seconds) at which to check connectivity of services with web endpoints." ).tag(config=True) + active_user_window = Integer(30 * 60, + help="Duration (in seconds) to determine the number of active users." + ).tag(config=True) data_files_path = Unicode(DATA_FILES_PATH, help="The location of jupyterhub data files (e.g. /usr/local/share/jupyterhub)" @@ -1786,8 +1789,7 @@ class JupyterHub(Application): spawner.last_activity = max(spawner.last_activity, dt) else: spawner.last_activity = dt - # FIXME: Make this configurable duration. 30 minutes for now! - if (now - user.last_activity).total_seconds() < 30 * 60: + if (now - user.last_activity).total_seconds() < self.active_user_window: active_users_count += 1 self.statsd.gauge('users.running', users_count) self.statsd.gauge('users.active', active_users_count)