Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Capistrano rename a file task

capistrano deployment

  • Please log in to reply
2 replies to this topic

#1 Vasspilka

Vasspilka

    Signalman

  • Members
  • 14 posts

Posted 24 December 2013 - 06:58 PM

Hello everyone and merry Christmas!

 

 

I am working on an Opensourced project I want to create, currently trying deploy to a VPS.

I'm working with Rails 4 and Capistrano 3 on Ubuntu, both on local machine and server.

 

I have a configuration file named application.yml that includes basic information about the application, as a Google Analytics script, the application name, Mailer configurations and such.

I want to create a task that would rename "application.example.yml" to "application.yml" before Capistrano runs deploy:migrate.

I wrote the task below and put it in config/deploy.rb:

before "deploy:migrate", "configure:application"
namespace :configure do
  task :application do
    run "#{try_sudo} cp #{current_path}/config/application.example.yml #{current_path}/config/application.yml"
  end
end

(I know cp copies the file but it also renames so it is fine.)

 

It does not seem to work. How can I rename "application.example.yml" before deploy:migrate runs?

GitHub Repository and deploy.rb

 

 

Also as I am moving forward with my App I seem to find more and more stuff I know little or nothing about, and would love it if someone experienced with Rails would be willing to become my "Mentor" by sharing with me his Skype (or any other communication service) so I could occasionally ask him my questions.



#2 Vasspilka

Vasspilka

    Signalman

  • Members
  • 14 posts

Posted 26 December 2013 - 12:24 PM   Best Answer

It seems that  with capistrano 3, the code should be like something like this

 

namespace :deploy do
# Your Server restart code, below is Passenger Example
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute "touch #{File.join(current_path,'tmp','restart.txt')}"
    end
  end
 before :updated, "configure:application"
end


namespace :configure do
  task :application do
   on roles(:app), in: :sequence, wait: 5 do
     execute "cp #{release_path}/config/application.example.yml #{release_path}/config/application.yml"
     execute "cp #{release_path}/config/database.example.yml #{release_path}/config/database.yml"
   end
  end
end
 


#3 stevieing

stevieing

    Dispatcher

  • Members
  • 40 posts

Posted 06 January 2014 - 02:19 PM

Hi

 

Funnily enough I am working on a personal project for a local club.

 

I have not finished the project but I am using exactly the same tools. I use a mac as my development environment, I have a virtual machine with Ubuntu as my staging server and this weekend I have just set up a production environment on Linode. I am using github to host my repository and I am deploying using Capistrano.

 

I am looking to do my first production deployment this week!

 

Regards

 

Steve.







Also tagged with one or more of these keywords: capistrano, deployment

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users