Upstart script which restarts service when file is created

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 then start on:

http://upstart.ubuntu.com/cookbook/#ordering-of-stop-start-operations

This means that you can use

start on file FILE=/etc/my-app/restart-requested.txt EVENT=modify
stop on file FILE=/etc/my-app/restart-requested.txt EVENT=modify

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.