Class: NubisRailsBoilerplate::Capistrano
- Inherits:
-
Object
- Object
- NubisRailsBoilerplate::Capistrano
- Defined in:
- lib/extra_capistrano.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#cap ⇒ Object
Returns the value of attribute cap.
-
#cap_path ⇒ Object
Returns the value of attribute cap_path.
Instance Method Summary collapse
- #check_git_repo ⇒ Object
-
#initialize(cap, cap_path, app_name) ⇒ Capistrano
constructor
A new instance of Capistrano.
- #load_configs ⇒ Object
- #load_modules ⇒ Object
- #load_permission ⇒ Object
Constructor Details
#initialize(cap, cap_path, app_name) ⇒ Capistrano
Returns a new instance of Capistrano.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/extra_capistrano.rb', line 4 def initialize(cap, cap_path, app_name) self.cap = cap self.cap_path = cap_path self.app_name = app_name cap.set :host_app_path, cap_path cap.set :repository, "[email protected]:nubis/#{app_name}.git" load_configs check_git_repo load_modules cap.set :user, "ubuntu" cap.set :application, app_name cap.set :deploy_to, "/home/ubuntu/apps/#{app_name}" cap.set :deploy_via, :remote_cache cap.set :use_sudo, false cap.set :scm, "git" cap.set :branch, "master" cap.set :keep_releases, 2 cap.[:pty] = true cap.[:forward_agent] = true cap.after "deploy", "deploy:cleanup" # keep only the last 5 releases end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
3 4 5 |
# File 'lib/extra_capistrano.rb', line 3 def app_name @app_name end |
#cap ⇒ Object
Returns the value of attribute cap.
3 4 5 |
# File 'lib/extra_capistrano.rb', line 3 def cap @cap end |
#cap_path ⇒ Object
Returns the value of attribute cap_path.
3 4 5 |
# File 'lib/extra_capistrano.rb', line 3 def cap_path @cap_path end |
Instance Method Details
#check_git_repo ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/extra_capistrano.rb', line 29 def check_git_repo output = `git pull origin master 2>&1` unless $?.success? puts "You need to be able to access #{cap.repository} before you deploy." puts "Make sure that it exists and you can access it before you continue." puts "The error was:" puts output exit 1 end end |
#load_configs ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/extra_capistrano.rb', line 61 def load_configs configs_path = File.('../../config/deploy.yml', cap_path) unless File.file?(configs_path) puts "You don't have the required configuration options to push to production" puts "I could not find a file named #{configs_path}" puts "Please request one and try again" exit 1 end configs = YAML.load_file(configs_path) unless configs.values.all? puts "You need to provide your configuration options before you can push." puts "Setup your server and database and input your data in: #{configs_path}" exit 1 end configs.each do |key, value| cap.set :configs, configs end cap.server configs['site_url'], :web, :app, :db, primary: true end |
#load_modules ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/extra_capistrano.rb', line 41 def load_modules path = File.('../capistrano_recipes', __FILE__) modules = Dir["#{path}/*.rb"].collect{|f| File.basename(f)} modules.sort.each do |m| puts "Loading cap module #{m}" cap.load File.join(path, m) end end |
#load_permission ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/extra_capistrano.rb', line 50 def = File.('../../config/permission.pem', cap_path) unless File.file?() puts "You don't have permission to push to the server" puts "I could not find a file named #{}" puts "Please request one and try again" exit 1 end cap.[:keys] = end |