ExApp lifecycle

The ExApp lifecycle is a set of communication rules (or protocols) between Nextcloud and the ExApp. They are required as for the microservice architecture of ExApp. This section is an overview, more details on that here: :ref:`app_installation_flow`, :ref:`app_deployment`.

ExApp lifecycle methods

When the ExApp is being installed in Nextcloud, there are several lifecycle steps happening. The ExApp lifecycle requires the following API endpoint handlers (in order):

  1. healthcheck: Docker container healthcheck

  2. /heartbeat: [required] ExApp heartbeat handler

  3. /init: [optional] ExApp initialization handler

  4. /enabled: [required] ExApp enable/disable handler

Healthcheck

Docker allows you to define a custom healthcheck script for your container (specified in the Dockerfile). You can define any custom container startup logic here if needed.

Heartbeat

The GET /heartbeat method is called periodically by Nextcloud to check the ExApp health status, i.e. if its webserver is running and receiving requests.

URL: GET http://localhost:2345/heartbeat

AppAPI expects a response with HTTP status 200. This step fails if the ExApp does not respond within 10 minutes.

Init

The POST /init endpoint is called after the ExApp is enabled in Nextcloud. This is a trigger for the ExApp to start its initialization process, e.g. downloading models, starter data, etc.

URL: POST http://localhost:2345/init

AppAPI expects a response with HTTP status 200.

The ExApp should update the init progress via the PUT /ocs/v2.php/apps/app_api/ex-app/status API request containing a { "progress": <number> } payload.

Enabled

The PUT /enabled?enabled=1|0 method is called when the ExApp is enabled or disabled in Nextcloud. The enabled query parameter is used to determine the ExApp state: 1 - enabled, 0 - disabled.

  • PUT http://localhost:2345/enabled?enabled=1 - enable ExApp, during this call ExApp should register all needed APIs

  • PUT http://localhost:2345/enabled?enabled=0 - disable ExApp, during this call ExApp should unregister all APIs

AppAPI expects a response with HTTP status 200. Any other status code will be considered as an error.

ExApp lifecycle scheme

Let's review a simple ExApp lifecycle scheme:

Nextcloud-side ExApp lifecycle methods

The Nextcloud-side ExApp lifecycle methods are the OCS APIs. You can find available AppAPI Nextcloud OCS APIs :ref:`here <app_api_nextcloud_apis>`.

AppAPI Authentication

Nextcloud requests to the ExApp are secured with :doc:`AppAPIAuth <../tech_details/Authentication>`. The ExApp should validate the authentication using the same algorithm as AppAPI does.

Cookies

Along with the AppAPIAuth, ExApp can utilize the Nextcloud cookies of the authenticated user, who made the request to the ExApp.