views:

21

answers:

2

I have a process I'd only like to run when I manually reboot my Rails app by touching tmp/restart.txt, not when Passenger restarts itself after an idle period. Is there anything I can check in my Rails code to determine whether a given reboot was one or the other?

+1  A: 

Maybe it's not answer you want, but I would simply create short script:

#!/bin/bash
touch tmp/restart.txt
some other things you want to do

Then when you restart aplication manualy through this script, you can do after it whatever you want.

klew
Very true. I was hoping for something I could use from within my Rails app, though.
abeger
In "some other things" you can add a rake task that will add some field in database or in a file. Then your application can read this value - then it knows if it was restarted, and after reading it should remove this value.
klew
+1 for separating it from the app start up. If these 'other things' aren't necessary to run every time you load your environment, why tie it to that? A rake task you run separately makes more sense than trying to determine what Passenger is doing.
Jeff Dallien
A: 

No, there is no way at the app level to differentiate them. What are you trying to do?

Hongli