The goal is to enable voca's users to stop their instance from their interface given that the decidim infrastructure is quite heavy. To achieve this, there are two important aspects:
Jelastic provides a REST API that allows us to start or stop an environment. However, there are a few limitations:
From the strapi backend side, we need to:
For this purpose, we created a Jelastic manifest that includes a CONTROL
parameter, which can have values such as "start," "stop," or "sleep."
Note: Jelastic also has a sleep attribute, but it's not supported by every Jelastic provider, so we're currently not using it.
All our instances are routed through a Traefik instance. This routing setup includes a middleware that intercepts 502 errors and displays a custom page. This allows us to provide a better error message than the standard Jelastic error page.
interactive
FieldWhen an instance is stopped, it's not possible to establish a gRPC connection with the backend. Consequently, we need to prevent voca's users from updating the instance while the environment is stopped.
To address this issue, we added an interactive
attribute to our GraphQL query for the Instance
. When this attribute is queried, we resolve it by performing a Jelastic lookup to determine the current status.