logo

Defining Dependencies in Templates

Ensure dependencies are fully started before launching your service.

PanPan

We are happy to introduce a new feature that lets you specify dependencies for your services directly in the template file.

Why It Matters

In the past, you could only control the order in which services start. This approach could lead to issues if some services took longer to start, potentially causing crashes if their dependencies weren't ready in time, and requiring manual restarts.

With the new dependency feature, you can now list the services your service depends on in the template. This ensures that your service only starts after all specified dependencies are fully ready, reducing the need for manual intervention during deployment.

How to Define Dependencies

To set dependencies in your template, simply add the dependencies field to the relevant service. This field lists the services that must be ready before your service starts. For example:

services:
    - name: redis
      template: PREBUILT
      # omitted
    - name: db
      template: PREBUILT
      # omitted
    - name: web
      template: PREBUILT
      dependencies:
        - db
        - redis

In this example, the web service will only start once both the db and redis services are up and running. For more details on configuring dependencies, check out the “dependencies” section in our documentation.

If you don’t specify any dependencies, services will continue to start in the order defined as before. Use this new feature to streamline your service startup process and avoid manual restarts.

Conclusion

The ability to define dependencies in your templates ensures that services start only when all required dependencies are ready. This improvement enhances the reliability of your deployments and eliminates the need for manual restarts. Try it out and let us know your feedback!