Created
October 15, 2012 14:18
-
-
Save chrismcg/3892678 to your computer and use it in GitHub Desktop.
Config for running Localeapp in staging/production on Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- poll every 5 minutes on :staging env | |
- poll on deployment only on :production env (not only dyno restart) | |
This assumes you've setup separate production/staging environments as described in: | |
https://devcenter.heroku.com/articles/multiple-environments | |
Especially the part about setting the RAILS_ENV/RACK_ENV on the staging environment. | |
The "polling" on deployment takes advantage of the fact that heroku runs the | |
asset:precompile task as part of building a slug. We hook into that to run the | |
fetch from locale app. You could avoid this by always pulling and committing | |
locally before pushing to heroku. | |
We also take advantage of any code in initializers being run at rails boot up | |
to pull the translations in staging every time the dyno restarts. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/localeapp.rake | |
namespace :localeapp do | |
desc "Fetch the latest translations from localeapp.com" | |
task :fetch_latest_translations => [:environment] do | |
if Rails.env.production? || Rails.env.staging? | |
Localeapp::CLI::Pull.new.execute | |
end | |
end | |
end | |
Rake::Task['assets:precompile'].enhance ['localeapp:fetch_latest_translations'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/localeapp.rb | |
require 'localeapp/rails' | |
Localeapp.configure do |config| | |
config.api_key = '<API KEY>' | |
config.poll_interval = 300 if Rails.env.staging? | |
config.polling_environments = [:development, :staging] | |
config.reloading_environments = [:development, :staging] | |
config.sending_environments = [:development, :staging] | |
end | |
# Pull latest when dyno restarts on staging | |
if Rails.env.staging? | |
Localeapp::CLI::Pull.new.execute | |
end |
Sorry @jerome, only saw your comment now. In the configuration above it will fetch on dyno restart in the staging environment only.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it mean it also fetches on dyno restart ?