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?
views:
21answers:
2
Q:
Is it possible to tell the difference between an automatic and manual restart in Phusion Passenger?
+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
2010-02-16 17:45:27
Very true. I was hoping for something I could use from within my Rails app, though.
abeger
2010-02-16 17:51:58
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
2010-02-16 17:55:35
+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
2010-02-17 03:42:36
A:
No, there is no way at the app level to differentiate them. What are you trying to do?
Hongli
2010-02-17 10:16:53