summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolas@nicolargo.com>2024-04-26 09:28:40 +0200
committernicolargo <nicolas@nicolargo.com>2024-04-26 09:28:40 +0200
commit11245a793a7bc39119ecbd0c18c9c27f4d057ed5 (patch)
treeb33226cb0c59f9d4263d5fabc8619a7334130f52
parentf2b232ebaf3ac735b3a130df9dc7e6856f0a6942 (diff)
parentdf66a7ffe9bf3b7cb8eebd10f234a3ab01f6ac0c (diff)
Merge branch 'issue2612' into develop
-rw-r--r--README.rst10
-rw-r--r--conf/glances.conf11
-rwxr-xr-xdocker-compose/glances.conf11
-rw-r--r--glances/outputs/glances_restful_api.py12
4 files changed, 32 insertions, 12 deletions
diff --git a/README.rst b/README.rst
index 5c86f7dc..4d80de92 100644
--- a/README.rst
+++ b/README.rst
@@ -201,8 +201,8 @@ or
*Note*: This is only supported on some GNU/Linux distributions and Mac OS X.
If you want to support other distributions, please contribute to `glancesautoinstall`_.
-Docker: the fun way
--------------------
+Docker: the cloudy way
+----------------------
Glances Docker images are availables. You can use it to monitor your
server and all your containers !
@@ -268,7 +268,8 @@ may not be the latest version and only basics plugins are enabled.
Note: The Debian package (and all other Debian-based distributions) do
not include anymore the JS statics files used by the Web interface
(see ``issue2021``). If you want to add it to your Glances installation,
-follow the instructions: ``issue2021comment``.
+follow the instructions: ``issue2021comment``. In Glances version 4 and
+higher, the path to the statics file is configurable (see ``issue2612``).
FreeBSD
-------
@@ -490,6 +491,7 @@ Glances is distributed under the LGPL version 3 license. See ``COPYING`` for mor
.. _package: https://repology.org/project/glances/versions
.. _sponsors: https://github.com/sponsors/nicolargo
.. _wishlist: https://www.amazon.fr/hz/wishlist/ls/BWAAQKWFR3FI?ref_=wl_share
-.. _issue2021: https://github.com/nicolargo/glances/issues/2021#issuecomment-1197831157
+.. _issue2021: https://github.com/nicolargo/glances/issues/2021
.. _issue2021comment: https://github.com/nicolargo/glances/issues/2021#issuecomment-1197831157
+.. _issue2612: https://github.com/nicolargo/glances/issues/2612
.. _Docker: https://github.com/nicolargo/glances/blob/develop/docs/docker.rst
diff --git a/conf/glances.conf b/conf/glances.conf
index e3f52711..3f1ca9a7 100644
--- a/conf/glances.conf
+++ b/conf/glances.conf
@@ -29,11 +29,18 @@ separator=True
#left_menu=network,wifi,connections,ports,diskio,fs,irq,folders,raid,smart,sensors,now
# Limit the number of processes to display (for the WebUI)
max_processes_display=25
-# Set the URL prefix (for the WebUI and the API)
+# Set URL prefix for the WebUI and the API
# Example: url_prefix=/glances/ => http://localhost/glances/
-# The final / is mandatory
+# Note: The final / is mandatory
# Default is no prefix (/)
#url_prefix=/glances/
+# Set root path for WebUI statics files
+# Why ? On Debian system, WebUI statics files are not provided.
+# You can download it in a specific folder
+# thanks to https://github.com/nicolargo/glances/issues/2021
+# then configure this folder with the webui_root_path key
+# Default is folder where glances_restfull_api.py is hosted
+#webui_root_path=
##############################################################################
# plugins
diff --git a/docker-compose/glances.conf b/docker-compose/glances.conf
index de023d07..644bee55 100755
--- a/docker-compose/glances.conf
+++ b/docker-compose/glances.conf
@@ -29,11 +29,18 @@ separator=True
#left_menu=network,wifi,connections,ports,diskio,fs,irq,folders,raid,smart,sensors,now
# Limit the number of processes to display (for the WebUI)
max_processes_display=25
-# Set the URL prefix (for the WebUI and the API)
+# Set URL prefix for the WebUI and the API
# Example: url_prefix=/glances/ => http://localhost/glances/
-# The final / is mandatory
+# Note: The final / is mandatory
# Default is no prefix (/)
#url_prefix=/glances/
+# Set root path for WebUI statics files
+# Why ? On Debian system, WebUI statics files are not provided.
+# You can download it in a specific folder
+# thanks to https://github.com/nicolargo/glances/issues/2021
+# then configure this folder with the webui_root_path key
+# Default is folder where glances_restfull_api.py is hosted
+#webui_root_path=
##############################################################################
# plugins
diff --git a/glances/outputs/glances_restful_api.py b/glances/outputs/glances_restful_api.py
index 35935c77..178a52f0 100644
--- a/glances/outputs/glances_restful_api.py
+++ b/glances/outputs/glances_restful_api.py
@@ -2,7 +2,7 @@
#
# This file is part of Glances.
#
-# SPDX-FileCopyrightText: 2023 Nicolas Hennion <nicolas@nicolargo.com>
+# SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com>
#
# SPDX-License-Identifier: LGPL-3.0-only
#
@@ -14,7 +14,6 @@ import sys
import tempfile
from io import open
import webbrowser
-import socket
from urllib.parse import urljoin
# Replace typing_extensions by typing when Python 3.8 support will be dropped
@@ -115,8 +114,13 @@ class GlancesRestfulApi(object):
self._app.include_router(APIRouter(prefix=self.url_prefix.rstrip('/')))
# Set path for WebUI
- self.STATIC_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'static/public')
- self.TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'static/templates')
+ webui_root_path = config.get_value('outputs',
+ 'webui_root_path',
+ default=os.path.dirname(os.path.realpath(__file__)))
+ if webui_root_path == '':
+ webui_root_path = os.path.dirname(os.path.realpath(__file__))
+ self.STATIC_PATH = os.path.join(webui_root_path, 'static/public')
+ self.TEMPLATE_PATH = os.path.join(webui_root_path, 'static/templates')
self._templates = Jinja2Templates(directory=self.TEMPLATE_PATH)
# FastAPI Enable CORS