forked from nicolargo/glances
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebserver.py
41 lines (31 loc) · 1.12 KB
/
webserver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#
# This file is part of Glances.
#
# SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com>
#
# SPDX-License-Identifier: LGPL-3.0-only
#
"""Glances Restful/API and Web based interface."""
from glances.globals import WINDOWS
from glances.outputs.glances_restful_api import GlancesRestfulApi
from glances.processes import glances_processes
from glances.stats import GlancesStats
class GlancesWebServer:
"""This class creates and manages the Glances Web server session."""
def __init__(self, config=None, args=None):
# Init stats
self.stats = GlancesStats(config, args)
if not WINDOWS and args.no_kernel_threads:
# Ignore kernel threads in process list
glances_processes.disable_kernel_threads()
# Initial system information update
self.stats.update()
# Init the Web server
self.web = GlancesRestfulApi(config=config, args=args)
def serve_forever(self):
"""Main loop for the Web server."""
self.web.start(self.stats)
def end(self):
"""End of the Web server."""
self.web.end()
self.stats.end()