This is actually pretty easy to do. Create a file, config/initializers/uptime.rb
, with:
YourApplication::BOOTED_AT = Time.now
Then it's just a case of comparing the current time to that time, which you can easily do in a helper method, using the time_ago_in_words
rails helper:
def uptime
time_ago_in_words(YourApplication::BOOTED_AT)
end
This gives you a human readable string saying how long the application has been running (give or take a few seconds for the startup).