Skip to content

Commit

Permalink
Store some things in config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Envek committed Oct 31, 2013
1 parent 5767692 commit bc85f33
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ nbproject/*
.bundle
.sass-cache/
public/assets/

config/settings.yml
config/settings.local.yml
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ gem 'rqrcode-rails3'
gem 'mini_magick'
gem 'routing_concerns'
gem 'deep_cloneable', '~> 1.5.5'
gem 'rails_config'

# Gems used only for assets and not required
# in production environments by default.
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ GEM
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
rails_config (0.3.2)
activesupport (>= 3.0)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
Expand Down Expand Up @@ -315,6 +317,7 @@ DEPENDENCIES
pg
poltergeist
rails (~> 3.2.0)
rails_config
rake
recordselect
redcarpet
Expand Down
51 changes: 51 additions & 0 deletions config/backup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Backup::Model.new(:taurus, 'Taurus backup configuration') do

db_config = YAML.load_file("#{File.dirname(__FILE__)}/database.yml")
app_config = YAML.load_file("#{File.dirname(__FILE__)}/settings.yml")

database PostgreSQL do |db|
db.name = db_config['production']['database']
db.username = db_config['production']['username']
db.password = db_config['production']['password']
db.host = db_config['production']['host']
db.port = db_config['production']['port']
db.skip_tables = ['sessions', 'sessions_id_seq']
db.additional_options = ['--clean']
end

compress_with Bzip2

store_with SCP do |server|
server.username = app_config['backup']['server']['username']
server.password = app_config['backup']['server']['password']
server.ip = app_config['backup']['server']['ip']
server.port = app_config['backup']['server']['port']
server.path = app_config['backup']['server']['path']
server.keep = app_config['backup']['server']['keep']
end

store_with Dropbox do |db|
db.api_key = app_config['backup']['dropbox']['api_key']
db.api_secret = app_config['backup']['dropbox']['api_secret']
db.path = app_config['backup']['dropbox']['path']
db.keep = 5
end

store_with Local do |local|
local.path = app_config['backup']['local']['path']
local.keep = app_config['backup']['local']['keep']
end

notify_by Mail do |mail|
mail.on_success = true
mail.on_failure = true

mail.from = "#{app_config['mailer']['user_name'] || 'andrey.novikov'}@#{app_config['mailer']['domain']|| 'amursu.ru'}"
mail.to = app_config['backup']['email']['to']
mail.address = app_config['mailer']['address']
mail.domain = app_config['mailer']['domain'] || 'amursu.ru'
mail.port = app_config['mailer']['port']
mail.authentication = app_config['mailer']['authentication'] if app_config['mailer']['authentication']
end

end
40 changes: 0 additions & 40 deletions config/backup.rb.example

This file was deleted.

6 changes: 3 additions & 3 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
after 'deploy:update_code', :roles => :app do
run "test -d #{deploy_to}/shared/config || mkdir #{deploy_to}/shared/config"
run "test -f #{deploy_to}/shared/config/database.yml || cp #{current_release}/config/database.yml.example #{deploy_to}/shared/config/database.yml"
run "test -f #{deploy_to}/shared/config/backup.rb || cp #{current_release}/config/backup.rb.example #{deploy_to}/shared/config/backup.rb"
run "test -f #{deploy_to}/shared/config/settings.yml || cp #{current_release}/config/settings.yml.example #{deploy_to}/shared/config/settings.yml"
run "test -f #{deploy_to}/shared/config/newrelic.yml || cp #{current_release}/config/newrelic.yml.example #{deploy_to}/shared/config/newrelic.yml"
end

Expand All @@ -46,8 +46,8 @@
run "rm -f #{current_release}/config/database.yml"
run "ln -s #{deploy_to}/shared/config/database.yml #{current_release}/config/database.yml"

run "rm -f #{current_release}/config/backup.rb"
run "ln -s #{deploy_to}/shared/config/backup.rb #{current_release}/config/backup.rb"
run "rm -f #{current_release}/config/settings.yml"
run "ln -s #{deploy_to}/shared/config/settings.yml #{current_release}/config/settings.yml"

run "rm -f #{current_release}/config/newrelic.yml"
run "ln -s #{deploy_to}/shared/config/newrelic.yml #{current_release}/config/newrelic.yml"
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
# Generate digests for assets URLs
config.assets.digest = true

GA.tracker = 'UA-39782423-3'
GA.tracker = Settings.analytics.id

end
3 changes: 3 additions & 0 deletions config/initializers/rails_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RailsConfig.setup do |config|
config.const_name = "Settings"
end
25 changes: 25 additions & 0 deletions config/settings.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
mailer:
address: mail.amursu.ru
port: 587

analytics:
id: UA-39782423-3

backup:
server:
username: user
password: password
ip: 1backup.server.ip.address
port: 22
path: /data/backups
keep: 50
dropbox:
api_key: my_key
api_secret: my_secret
path: /
keep: 5
local:
path: ~/backups
keep: 100
email:
to: [email protected]

0 comments on commit bc85f33

Please sign in to comment.