Since 2.31, we support service ordering within a single snap using
before keywords, as described here The snap format. However, we still lack support for cross-snap service ordering.
In short, the idea is that a snap
foo, defining a service
foo.app), can request the service to be ordered
other from snap
After/Before= stanzas generated based on the declaration define a loose coupling between the services involved. Meaning, the service mentioned in the right side of the declaration does not need to be defined or started.
I propose to extend the current snap.yaml syntax with support for external services like so:
name: my-snap apps: foo: command: bin/start-foo daemon: simple # declare to be started before service 'baz' from snap 'bar' before: [snap.bar.baz] bar: command: bin/start-bar daemon: simple # declare to be started after service 'daz' from snap 'zed' after: [snap.zed.daz] # referring to own apps is illegal before: [snap.my-snap.app]
- the syntax feels familiar, external dependencies are clearly visible
- matches our way of naming the units
- we can validate dependency cycles within a snap to a limited extent (will to add ‘mocked’ external dependencies just for validation)
- syntax can be extended to support system services (eg. with
- depending on a service from other snap, while the service got renamed
- ordering after/before services from other snap does not make that snap a dependncy
- during installation, only the services from the current snap will be started in the right order