Skip to content

Commit

Permalink
Don't do init_backup every time db:create is run because it might be …
Browse files Browse the repository at this point in the history
…slow if there is a large database that already exists. This matters especially after changing the running instances (e.g. adding more app servers) because when you do ec2onrails:setup it will run db:create (harmless) on the existing db.

Added a TODO in create_database to do the backup then, but first we need to check for the existence of the db and exit if it exists.
  • Loading branch information
pauldowman committed Oct 22, 2009
1 parent 64ba290 commit 4c6bdf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion gem/lib/ec2onrails/recipes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

after "deploy:symlink", "ec2onrails:server:set_roles", "ec2onrails:server:init_services"
after "deploy:symlink", "ec2onrails:server:purge_proxy_cache"
after "ec2onrails:db:create", "ec2onrails:db:init_backup"

on :load do
before "deploy:symlink", "ec2onrails:server:run_rails_rake_gems_install"
Expand Down
5 changes: 4 additions & 1 deletion gem/lib/ec2onrails/recipes/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
puts " * Pausing to give MySQL some time to start up..."
sleep 20

# TODO run init_backup after creating the db. This might be slow, so we need to
# check if the db exists, and exit without doing any of this if it exists.

run %{mysql -u root -e "drop database if exists test; flush privileges;"}
# removing anonymous mysql accounts
run %{mysql -u root -D mysql -e "delete from db where User = ''; flush privileges;"}
Expand All @@ -65,7 +68,7 @@
run %{mysql -u root -e "create database if not exists \\`#{cfg[:db_name]}\\`;"}
run %{mysql -u root -e "grant all on \\`#{cfg[:db_name]}\\`.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
run %{mysql -u root -e "grant reload on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
run %{mysql -u root -e "grant super on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
run %{mysql -u root -e "grant super on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
end

desc <<-DESC
Expand Down

0 comments on commit 4c6bdf8

Please sign in to comment.