pyfebiopt.monitoring.service
============================

.. py:module:: pyfebiopt.monitoring.service

.. autoapi-nested-parse::

   CLI helpers for installing and running the monitoring service.



Attributes
----------

.. autoapisummary::

   pyfebiopt.monitoring.service.UNIT_TEMPLATE


Functions
---------

.. autoapisummary::

   pyfebiopt.monitoring.service.ensure_dependencies
   pyfebiopt.monitoring.service.run_service
   pyfebiopt.monitoring.service.install_service
   pyfebiopt.monitoring.service.uninstall_service
   pyfebiopt.monitoring.service.parse_args
   pyfebiopt.monitoring.service.main


Module Contents
---------------

.. py:data:: UNIT_TEMPLATE
   :value: Multiline-String

   .. raw:: html

      <details><summary>Show Value</summary>

   .. code-block:: python

      """[Unit]
      Description=pyfebiopt monitoring web service
      After=network.target
      
      [Service]
      Type=simple
      ExecStart={python} -m pyfebiopt.monitoring.service run --registry {registry} --socket {socket} --host {host} --port {port}
      Restart=on-failure
      RestartSec=2
      
      [Install]
      WantedBy=default.target
      """

   .. raw:: html

      </details>



.. py:function:: ensure_dependencies() -> None

   Ensure the optional monitoring stack is available.


.. py:function:: run_service(*, registry: pathlib.Path | None = None, socket: pathlib.Path | None = None, host: str | None = None, port: int | None = None) -> int

   Start the monitoring web service with the given overrides.

   :returns: Process exit code (0 on normal exit).
   :rtype: int


.. py:function:: install_service(*, user: bool = True, force: bool = False, host: str = '127.0.0.1', port: int = 8765) -> None

   Install the systemd unit for the monitoring service.


.. py:function:: uninstall_service(*, user: bool = True) -> None

   Disable and remove the monitoring systemd unit.


.. py:function:: parse_args(argv: list[str] | None = None) -> argparse.Namespace

   Parse the CLI arguments for the monitoring helper.

   :returns: Parsed arguments.
   :rtype: argparse.Namespace


.. py:function:: main(argv: list[str] | None = None) -> int

   Dispatch commands from the monitoring helper CLI.

   :returns: Process exit code.
   :rtype: int


