At least once a day, all Heroku Dynos are rebooted, which starts with a SigTerm command, followed be a SigKill about 10 seconds later.
When the SigTerm command is sent to our Heroku Dyno, we would like to start a special logging job that sends information to Papertrail for the remaining 10 seconds of the Dyno's life before SigKill is issued.
We need a bash or php script that can catch sigterm (but still allows the other processes to hear it as well) and starts a logging job.
You don't have to write the logging job but your script must be able to call another script which will do the logging, either PHP or bash. We will write this other script, you don't have any responsibility for it.
Also, your script should not cause any adverse affects or slow anything down. It should be well commented and compact.
You can develop & test your solution with any free Heroku Dyno, and by restarting the dyno from Heroku's web interface...