blob: e61ca32b37ee370b878f4da120f79b05fd921de0 (
plain)
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
42
43
44
|
# -*- coding: utf-8 -*-
#
# This file is part of Glances.
#
# SPDX-FileCopyrightText: 2023 Nicolas Hennion <nicolas@nicolargo.com>
#
# SPDX-License-Identifier: LGPL-3.0-only
#
"""Glances Restful/API and Web based interface."""
from glances.logger import logger
from glances.globals import WINDOWS
from glances.processes import glances_processes
from glances.stats import GlancesStats
from glances.outputs.glances_restful_api import GlancesRestfulApi
class GlancesWebServer(object):
"""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()
|