Adding ‘whenever’ gem to Rails environment caused warning
I switched this week from Rufus Scheduler to Whenever. The difference between them is that Rufus Scheduler starts per Rails Instance a background Ruby process to handle the scheduling and Whenever uses cron jobs. Rufus Scheduler is a nice gem and which is easy to use, but for me it seems an overhead to run a second process for each Rails instance (I know that this can be avoided, but what when the Rails process with Rufus dies and all other Rails instances are running?) On the other hand, cron job and Whenever are also easy to use and don’t add much overhead to the server.
When I added Whenever, I got a warning every time I started Rails:
.../vendor/rails/railties/lib/rails/version.rb:3: warning: already initialized constant MAJOR .../vendor/rails/railties/lib/rails/version.rb:3: warning: already initialized constant MINOR .../vendor/rails/railties/lib/rails/version.rb:3: warning: already initialized constant TINY .../vendor/rails/railties/lib/rails/version.rb:3: warning: already initialized constant STRING
The problem was that I added a require statement in environment.rb:
require 'whenever'
which isn’t necessary in Rails 2.1 and above. I know it stands in the install instructions, but when I am in a rush, I sometimes doesn’t read it carefully. Even if I should. So if you use the Whenever gem and Rails 2.1 and above and you get the warning from above, it is your fault and not Whenever’s. That said, Whenever does quite a good job for TimeWhale. I am using it for running a Twitter Job that handles tracking time directly from Twitter.
Related posts:
