Service start order

When multiple services need to be started together, they’re started in order according to the before and after in the layer configuration. Pebble waits 1 second after starting each service to ensure the command doesn’t exit too quickly.

The before option is a list of services that this service must start before (it may or may not requires them, see Service dependencies). Or if it’s easier to specify this ordering the other way around, after is a list of services that this service must start after.

Note

Currently, before and after are of limited usefulness, because Pebble only waits 1 second before moving on to start the next service, with no additional checks that the previous service is operating correctly.

If the configuration of before and after for the services results in a cycle, an error will be returned when the Pebble daemon starts (and the plan is loaded) or when a layer that causes a cycle is added.

The before and after options are not designed for scenarios where you need to start service B only after service A has exited. A common workaround is to combine both services into a single service definition, using a command such as bash -c 'run-service-a && run-service-b' to ensure that service B starts only after service A exits successfully.

For comparison, in systemd this can be achieved by running service B from service A’s ExecStopPost= directive. In supervisord, this can be achieved using event listeners.