Code to be run on server start up

In Rails 4.2, is there a place where I can put code that I want to be called immediately after the rails server starts up (as opposed to when an HTTP request comes in). In other words, I want my code executed right after I do a "rails server" command or a "heroku restart."

As one simple example, suppose I wanted to maintain an item in the database that would simply count system reloads. Where would that code go?

Initializers are called *during* startup; would that do?

I'm not sure. Would I have access to the database, either through ActiveRecords or ?

Pardon my ignorance here. I'm not sure where to find documentation concerning the "transition" between getting all the framework initialized and the "normal" rails stuff where you're just responding to http requests one-by-one.

-Mike

OK, well it does appear to work. I created a file in config/initializers and put my code in there. It seems to be running as hoped for. At least in development mode. Thank you Hassan.

-Mike

As you’ve noted, config/initializers is the right place for this. For reference or general curiosity, there’s a detailed guide to the Rails initialization process here:

http://guides.rubyonrails.org/initialization.html

–Matt Jones