Closed sachinlala closed 6 years ago
Hello @sachinlala. It sounds like what you want is a watch
and not an event trigger, have you looked at those?
Event triggers defined under jobs
only interact with services under the control of ContainerPilot within a single container. A watch
defines how ContainerPilot can watch for external service changes through Consul's service registry.
https://www.joyent.com/containerpilot/docs/configuration/watches
Since watches
are a construct within Consul, the configuration defines them separately from jobs
. You can still reference the watch from within a job's configuration, like so...
jobs: [
{
name: "B",
exec: "/var/tmp/startB.sh",
when: {
source: "watch.A",
each: "healthy"
}
}
],
watches: [
{
name: "A",
interval: 3
}
]
Notice the prepended hook under source
, watch.
, this links the source of the event to an external watch
in Consul.
Hope that answers your question or puts you on the right path.
Hi @cheapRoc - this does answer my question and it's worked good. Will be further helpful to include this semantic (specifically the point about watch.<service_name>
in the source
tag) in the main documentation.
Thanks a lot for your help.
Scenario
Service 'B' depends on service 'A' i.e. the startup for service B should not be initiated till service A is healthy. Both the services register in Consul.
Issue
We're using the 'when' directive to ensure the dependency check is done. What we're observing is:
Version
We're using the version 3.4.2 of containerpilot.
Configuration (app.json5)
Questions
For now, we have added a delay in the startup of service B to tactically circumvent the issue, but would like to utilize the 'when' directive rightfully.