You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

4 years ago
  1. # -*- coding: utf-8 -*-
  2. #
  3. # This file is part of Glances.
  4. #
  5. # Copyright (C) 2018 Nicolargo <nicolas@nicolargo.com>
  6. #
  7. # Glances is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU Lesser General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # Glances is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. """Glances Web Interface (Bottle based)."""
  20. from glances.globals import WINDOWS
  21. from glances.processes import glances_processes
  22. from glances.stats import GlancesStats
  23. from glances.outputs.glances_bottle import GlancesBottle
  24. class GlancesWebServer(object):
  25. """This class creates and manages the Glances Web server session."""
  26. def __init__(self, config=None, args=None):
  27. # Init stats
  28. self.stats = GlancesStats(config, args)
  29. if not WINDOWS and args.no_kernel_threads:
  30. # Ignore kernel threads in process list
  31. glances_processes.disable_kernel_threads()
  32. # Initial system informations update
  33. self.stats.update()
  34. # Init the Bottle Web server
  35. self.web = GlancesBottle(config=config, args=args)
  36. def serve_forever(self):
  37. """Main loop for the Web server."""
  38. self.web.start(self.stats)
  39. def end(self):
  40. """End of the Web server."""
  41. self.web.end()
  42. self.stats.end()