cylc / cylc-uiserver

A Jupyter Server extension that serves the cylc-ui web application for monitoring and controlling Cylc workflows.
https://cylc.org
GNU General Public License v3.0
15 stars 18 forks source link

server: implement the current_activity interface #611

Open oliver-sanders opened 4 months ago

oliver-sanders commented 4 months ago

Jupyter Server extension applications may implement a current_activity interface.

This is used to inform Jupyter Server of any activity with the extension for the purposes of implementing the shutdown_no_activity_timeout which is a handy way of killing idle servers.

https://github.com/jupyter-server/jupyter_server/blob/b85c15b5678cd6ea9de28e4f547bc0dfef0a69c7/jupyter_server/extension/application.py#L449-L451

In Cylc UI Server, we would consider "activity" to mean GraphQL queries or active websocket connections. So this would require listing active websocket connections which is an issue which will also need to be solved for #585 and #597.

There are currently two caveats to this approach:

  1. Currently, if a client disconnects, the server might not find out about this until the next update is sent to the client.
    • This means that websocket connections may remain alive indefinitely if no workflows are active.
    • This can be resolved by configuring a websocket ping interval, however, we are currently waiting for an upstream fix to go in before we can do this.
    • https://github.com/cylc/cylc-uiserver/issues/557
  2. The Cylc UI app may remain active as long as it is open somewhere in a browser tab.