I have created my own upstart script in /etc/init, which I can start and stop.
Now I want that service to be restarted when a file (/etc/my-app/restart-requested.txt) exists (or better is touched).
My solution with previous /etc/init.d/ service was a cron-job which regularily checked for the restart-file and called restart when the file existed.
Is there a better solution with upstart?
6 years later I've found out that upstarts guarantees that it first processes
stop on
and thenstart on
:http://upstart.ubuntu.com/cookbook/#ordering-of-stop-start-operations
This means that you can use
Probably you don't need it anymore but I've faced same issue and found your question so maybe someone can use this solution in the future as well.
/etc/my-app/restart-requested.txt IN_CLOSE_WRITE restart myservice
into/etc/incron.d/myservice