diff --git a/doc/how_to/profiling/admin.md b/doc/how_to/profiling/admin.md index 5f47c39246..193f29f911 100644 --- a/doc/how_to/profiling/admin.md +++ b/doc/how_to/profiling/admin.md @@ -6,8 +6,22 @@ This guide addresses how to enable the admin Panel to begin monitoring resource The `/admin` panel provides an overview of the current application and provides tools for debugging and profiling. It can be enabled by passing the ``--admin`` argument to the `panel serve` command. +```bash +panel serve my-app.py --admin +``` + When you have successfully enabled it you should be able to visit the `/admin` endpoint of your application, e.g. if you are serving locally on port 5006, visit `http://localhost:5006/admin`. You should now be greeted with the overview page, which provides some details about currently active sessions, running versions and resource usage (if `psutil` is installed): +## Changing the admin panel endpoint + +You can change the endpoint that the admin page is rendered at by using the flag `--admin-endpoint="/my-new-admin-endpoint"`. This will change where the admin endpoint is in the Bokeh server, and cause a `404: Not Found` page to be shown if you navigate to the default `/admin` path discussed above. As an example, using the following command to start your Panel app + +```bash +panel serve my-app.py --admin --admin-endpoint="/my-new-admin-endpoint" +``` + +and navigating to [http://localhost:5006/admin](http://localhost:5006/admin) will result in a 404 page, however, navigating to [http://localhost:5006/my-new-admin-endpoint](http://localhost:5006/my-new-admin-endpoint) will result in the admin panel. + ## Related Resources diff --git a/panel/command/serve.py b/panel/command/serve.py index 452538fe12..86de98df0d 100644 --- a/panel/command/serve.py +++ b/panel/command/serve.py @@ -182,11 +182,11 @@ class Serve(_BkServe): action = 'store_true', help = "Whether to add an admin panel." )), - ('--admin-panel-name', dict( + ('--admin-endpoint', dict( metavar = "KEY=VALUE", nargs = '+', - help = "Name to use for the admin panel.", - default = '/admin' + help = "Name to use for the admin endpoint.", + default = None )), ('--admin-log-level', dict( action = 'store', @@ -355,8 +355,12 @@ def customize_kwargs(self, args, server_kwargs): from ..io.admin import admin_panel from ..io.server import per_app_patterns - # NOTE: `admin_panel_name` returns a list. - admin_path = args.admin_panel_name[0] if args.admin_panel_name else "/admin" + # NOTE: `admin_endpoint` returns a list. If the command line flag + # `--admin-endpoint` is not used, then we default to the `/admin` path. + admin_path = "/admin" + if args.admin_endpoint: + admin_path = args.admin_endpoint[0] + config._admin = True app = Application(FunctionHandler(admin_panel)) unused_timeout = args.check_unused_sessions or 15000 diff --git a/panel/config.py b/panel/config.py index 65f5d438f9..c8e9f94a12 100644 --- a/panel/config.py +++ b/panel/config.py @@ -218,7 +218,7 @@ class _config(_base_config): _admin = param.Boolean(default=False, doc="Whether the admin panel was enabled.") - _admin_panel_name = param.String(default=None, doc="Name to use for the admin panel.") + _admin_endpoint = param.String(default=None, doc="Name to use for the admin endpoint.") _admin_log_level = param.Selector( default='DEBUG', objects=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], @@ -458,8 +458,8 @@ def _doc_build(self): return os.environ.get('PANEL_DOC_BUILD') @property - def admin_panel_name(self): - return os.environ.get('PANEL_ADMIN_PANEL_NAME', self._admin_panel_name) + def admin_endpoint(self): + return os.environ.get('PANEL_ADMIN_ENDPOINT', self._admin_endpoint) @property def admin_log_level(self):