Class: Yad::Framework::Rails
- Inherits:
-
Object
- Object
- Yad::Framework::Rails
- Defined in:
- lib/yad/framework/rails.rb
Class Method Summary collapse
- .build_setup_command(shared_directory, options = {}) ⇒ Object
- .build_update_command(new_release_directory, shared_directory, options = {}) ⇒ Object
- .define_tasks ⇒ Object
Class Method Details
.build_setup_command(shared_directory, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/yad/framework/rails.rb', line 4 def self.build_setup_command(shared_directory, = {}) = { :umask => '02' } = .merge() dirs = [File.join(shared_directory, "log"), File.join(shared_directory, "pids"), File.join(shared_directory, "system") ] "umask #{[:umask]} && mkdir -p #{dirs.join(' ')}" end |
.build_update_command(new_release_directory, shared_directory, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/yad/framework/rails.rb', line 14 def self.build_update_command(new_release_directory, shared_directory, = {}) = { :app_env => 'production', :framework_update_db_config_via => 'none' } = .merge() commands = ["rm -rf #{new_release_directory}/log #{new_release_directory}/public/system #{new_release_directory}/tmp/pids", "mkdir -p #{new_release_directory}/tmp", "ln -s #{shared_directory}/log #{new_release_directory}/log", "ln -s #{shared_directory}/pids #{new_release_directory}/tmp/pids", "ln -s #{shared_directory}/system #{new_release_directory}/public/system" ] case [:framework_update_db_config_via].to_sym when :copy commands << "cp -f #{new_release_directory}/config/database_#{[:app_env]}.yml #{new_release_directory}/config/database.yml" when :symlink commands << "ln -nfs #{shared_directory}/config/database.yml #{new_release_directory}/config/database.yml" end commands.join(" && ") end |
.define_tasks ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/yad/framework/rails.rb', line 35 def self.define_tasks return if @tasks_already_defined @tasks_already_defined = true namespace :yad do namespace :framework do desc "Performs additional setup needed for the framework" remote_task :setup, :roles => :app do = Rake::RemoteTask.(:umask) cmd = Yad::Framework::Rails.build_setup_command(shared_path, ) run(cmd) puts("Rails set up on #{target_host}") end desc "Updates the framework configuration and working directories after a new release has been exported" remote_task :update, :roles => :app do = Rake::RemoteTask.(:app_env, :framework_update_db_config_via) cmd = Yad::Framework::Rails.build_update_command(release_path, shared_path, ) run(cmd) puts("Rails shared paths and files updated on #{target_host}") end end end end |