Controlling Jelastic Environment
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:
- Remote environment control
- Routing management
Remote Environment Control
Jelastic provides a REST API that allows us to start or stop an environment. However, there are a few limitations:
- An already stopped environment cannot be stopped.
- An environment cannot be modified while it's being updated.
From the strapi backend side, we need to:
- Check the status of the environment.
- Call start or stop commands on the environment.
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.
Routing
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
Field
When 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.