Eu tenho os três serviços a seguir: apache2 , serviceFirst e serviceSecond .
Desejo executar serviceFirst quando apache2 estiver em execução
Desejo executar serviceSecond quando serviceFirst estiver em execução
arquivo /etc/init/serviceFirst.conf :
# Info
description "UDP server"
author "Reggie Williams"
# Events
start on apache2
stop on shutdown
# Automatically respawn
respawn
respawn limit 20 5
script
exec >/var/log/test.debug 2>&1 #so I can track when the service runs
echo Gotcha...
[ $(exec /usr/bin/php -f /var/www/server/udp/bin/serverrunner.php) = 'critical_error' ] && (stop; exit 1;)
end script
arquivo /etc/init/serviceSecond.conf :
# Info
description "UDP client"
author "Reggie Williams"
# Events
start on (started serviceFirst)
stop on shutdown
# Automatically respawn
respawn
respawn limit 20 5
script
exec >/var/log/test2.debug 2>&1 #so I can track when the service runs
echo Gotcha2...
[ $(exec /usr/bin/php -f /var/www/server/udp/bin/clientrunner.php) = 'critical_error' ] && (stop; exit 1;)
end script
Então, nesses dois serviços, eu executo meus scripts. Além disso, eu crio um arquivo por serviço e os salvo em /var/log .
No entanto, quando verifico os timestamps de criação desses dois arquivos, vejo que test.debug foi criado depois de test2.debug .
Então, minha pergunta é: como isso é possível e como garantir que serviceSecond seja realmente iniciado após serviceFirst e apache ?