Acho que você está procurando PartOf
:
PartOf= Configures dependencies similar to Requires=, but limited to stopping and restarting of units. When systemd stops or restarts the units listed here, the action is propagated to this unit. Note that this is a one-way dependency — changes to this unit do not affect the listed units.
When PartOf=b.service is used on a.service, this dependency will show as ConsistsOf=a.service in property listing of b.service. ConsistsOf= dependency cannot be specified directly.
Adicione PartOf=postgresql.service
ao arquivo de unidade de seu aplicativo da Web, recarregue systemctl-daemon
e teste.
E para resolver a situação em que seu aplicativo da web terá que iniciar automaticamente depois que postgresql.service
começar, você poderá combinar PartOf
com Wants
, mas no arquivo de unidade postgresql
:
Wants= A weaker version of Requires=. Units listed in this option will be started if the configuring unit is. However, if the listed units fail to start or cannot be added to the transaction, this has no impact on the validity of the transaction as a whole. This is the recommended way to hook start-up of one unit to the start-up of another unit.
Note that dependencies of this type may also be configured outside of the unit configuration file by adding symlinks to a .wants/ directory accompanying the unit file. For details, see above.