mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-12 20:43:02 +00:00
fixed running_servers count
This commit is contained in:
@@ -759,6 +759,7 @@ class BaseHandler(RequestHandler):
|
|||||||
active_counts['spawn_pending'] + active_counts['proxy_pending']
|
active_counts['spawn_pending'] + active_counts['proxy_pending']
|
||||||
)
|
)
|
||||||
active_count = active_counts['active']
|
active_count = active_counts['active']
|
||||||
|
RUNNING_SERVERS.set(active_count)
|
||||||
|
|
||||||
concurrent_spawn_limit = self.concurrent_spawn_limit
|
concurrent_spawn_limit = self.concurrent_spawn_limit
|
||||||
active_server_limit = self.active_server_limit
|
active_server_limit = self.active_server_limit
|
||||||
@@ -842,7 +843,6 @@ class BaseHandler(RequestHandler):
|
|||||||
"User %s took %.3f seconds to start", user_server_name, toc - tic
|
"User %s took %.3f seconds to start", user_server_name, toc - tic
|
||||||
)
|
)
|
||||||
self.statsd.timing('spawner.success', (toc - tic) * 1000)
|
self.statsd.timing('spawner.success', (toc - tic) * 1000)
|
||||||
RUNNING_SERVERS.inc()
|
|
||||||
SERVER_SPAWN_DURATION_SECONDS.labels(
|
SERVER_SPAWN_DURATION_SECONDS.labels(
|
||||||
status=ServerSpawnStatus.success
|
status=ServerSpawnStatus.success
|
||||||
).observe(time.perf_counter() - spawn_start_time)
|
).observe(time.perf_counter() - spawn_start_time)
|
||||||
@@ -854,6 +854,7 @@ class BaseHandler(RequestHandler):
|
|||||||
PROXY_ADD_DURATION_SECONDS.labels(status='success').observe(
|
PROXY_ADD_DURATION_SECONDS.labels(status='success').observe(
|
||||||
time.perf_counter() - proxy_add_start_time
|
time.perf_counter() - proxy_add_start_time
|
||||||
)
|
)
|
||||||
|
RUNNING_SERVERS.inc()
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.exception("Failed to add %s to proxy!", user_server_name)
|
self.log.exception("Failed to add %s to proxy!", user_server_name)
|
||||||
self.log.error(
|
self.log.error(
|
||||||
@@ -1022,7 +1023,6 @@ class BaseHandler(RequestHandler):
|
|||||||
"User %s server took %.3f seconds to stop", user.name, toc - tic
|
"User %s server took %.3f seconds to stop", user.name, toc - tic
|
||||||
)
|
)
|
||||||
self.statsd.timing('spawner.stop', (toc - tic) * 1000)
|
self.statsd.timing('spawner.stop', (toc - tic) * 1000)
|
||||||
RUNNING_SERVERS.dec()
|
|
||||||
SERVER_STOP_DURATION_SECONDS.labels(
|
SERVER_STOP_DURATION_SECONDS.labels(
|
||||||
status=ServerStopStatus.success
|
status=ServerStopStatus.success
|
||||||
).observe(toc - tic)
|
).observe(toc - tic)
|
||||||
|
@@ -39,9 +39,7 @@ RUNNING_SERVERS = Gauge(
|
|||||||
'running_servers', 'the number of user servers currently running'
|
'running_servers', 'the number of user servers currently running'
|
||||||
)
|
)
|
||||||
|
|
||||||
RUNNING_SERVERS.set(0)
|
TOTAL_USERS = Gauge('total_users', 'total number of users')
|
||||||
|
|
||||||
TOTAL_USERS = Gauge('total_users', 'toal number of users')
|
|
||||||
|
|
||||||
TOTAL_USERS.set(0)
|
TOTAL_USERS.set(0)
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ from .crypto import decrypt
|
|||||||
from .crypto import encrypt
|
from .crypto import encrypt
|
||||||
from .crypto import EncryptionUnavailable
|
from .crypto import EncryptionUnavailable
|
||||||
from .crypto import InvalidToken
|
from .crypto import InvalidToken
|
||||||
|
from .metrics import RUNNING_SERVERS
|
||||||
from .metrics import TOTAL_USERS
|
from .metrics import TOTAL_USERS
|
||||||
from .objects import Server
|
from .objects import Server
|
||||||
from .spawner import LocalProcessSpawner
|
from .spawner import LocalProcessSpawner
|
||||||
@@ -753,6 +754,7 @@ class User:
|
|||||||
self.db.delete(oauth_client)
|
self.db.delete(oauth_client)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
self.log.debug("Finished stopping %s", spawner._log_name)
|
self.log.debug("Finished stopping %s", spawner._log_name)
|
||||||
|
RUNNING_SERVERS.dec()
|
||||||
finally:
|
finally:
|
||||||
spawner.orm_spawner.started = None
|
spawner.orm_spawner.started = None
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
Reference in New Issue
Block a user