marcosgz-cap-recipe 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/hash/reverse_merge'
2
+ require 'active_support/core_ext/hash/slice'
2
3
  require 'capistrano'
3
4
 
4
5
  Dir.glob(File.join(File.dirname(__FILE__), '/recipes/*.rb')).sort.each { |f| load f }
@@ -19,11 +19,11 @@ Capistrano::Configuration.instance(:must_exist).load do
19
19
  namespace :create do
20
20
  task :dirs, :roles => :app do
21
21
  deploy.setup
22
- commands = %w(config uploads backup bundle pids tmp/cache public/cache).map do |path|
22
+ commands = %w(config uploads backup bundle pids tmp/cache public/cache public/assets).map do |path|
23
23
  "if [ ! -d '#{path}' ]; then mkdir -p #{path}; fi;"
24
24
  end
25
25
  run "cd #{shared_path}; #{commands.join(' ')}"
26
- run "chmod 777 #{shared_path}/public/cache #{shared_path}/tmp/cache"
26
+ run "chmod 777 #{shared_path}/public/cache #{shared_path}/public/assets #{shared_path}/tmp/cache"
27
27
  end
28
28
 
29
29
 
@@ -17,7 +17,7 @@ Capistrano::Configuration.instance(:must_exist).load do
17
17
  namespace :gateways do
18
18
  namespace :setup do
19
19
  desc "Upload configs"
20
- task :default, :roles => :db do
20
+ task :default, :roles => :app do
21
21
  if exists?(:gateways_setup_settings)
22
22
  set(:recipe_settings) { fetch(:gateways_setup_settings, {}) }
23
23
  put template.render(fetch(:gateways_template)), fetch(:gateways_remote_file)
@@ -13,7 +13,7 @@ Capistrano::Configuration.instance(:must_exist).load do
13
13
  namespace :mailer do
14
14
  namespace :setup do
15
15
  desc "Upload configs"
16
- task :default, :roles => :db do
16
+ task :default, :roles => :app do
17
17
  if exists?(:mailer_setup_settings)
18
18
  set :recipe_settings, fetch(:mailer_setup_settings, {})
19
19
  put template.render(fetch(:mailer_template)), fetch(:mailer_remote_file)
@@ -194,7 +194,7 @@ Capistrano::Configuration.instance(:must_exist).load do
194
194
  namespace :newrelic do
195
195
  namespace :setup do
196
196
  desc "Upload configs"
197
- task :default, :roles => :db do
197
+ task :default, :roles => :app do
198
198
  if exists?(:newrelic_setup_settings)
199
199
  set(:recipe_settings) { newrelic_template_settings }
200
200
  put template.render(fetch(:newrelic_template)), fetch(:newrelic_remote_file)
@@ -7,20 +7,27 @@
7
7
 
8
8
  Capistrano::Configuration.instance(:must_exist).load do
9
9
 
10
- set(:apache_sites_available) { "/home/#{user}/configs/apache/sites-available" }
11
- set(:apache_sites_enabled) { "/home/#{user}/configs/apache/sites-enabled" }
12
- set(:apache_remote_file) { File.join(apache_sites_available, "#{application}.conf") } unless exists?(:apache_remote_file)
13
- set(:apache_template, 'passenger.conf.erb') unless exists?(:apache_template)
14
-
15
10
  # task: `passenger:setup'
16
11
  def passenger_template_settings
17
12
  fetch(:passenger_setup_settings, {}).reverse_merge({
13
+ 'sites_available' => fetch(:apache_sites_available, "/home/#{user}/configs/apache/sites-available"),
14
+ 'sites_enabled' => fetch(:apache_sites_enabled, "/home/#{user}/configs/apache/sites-enabled"),
15
+ 'vhost_filename' => fetch(:apache_vhost_filename) { "#{application}.conf" },
16
+ 'template_filename' => fetch(:apache_template_filename) { 'passenger.conf.erb' },
18
17
  'server_name' => fetch(:domain),
19
18
  'document_root' => File.join(fetch(:current_path), 'public'),
20
19
  'rails_env' => fetch(:rails_env, 'production')
21
20
  })
22
21
  end
23
22
 
23
+ def apache_available_vhost
24
+ File.join(*passenger_template_settings.slice('sites_available', 'vhost_filename').values)
25
+ end
26
+
27
+ def apache_enabled_vhost
28
+ File.join(*passenger_template_settings.slice('sites_enabled', 'vhost_filename').values)
29
+ end
30
+
24
31
  namespace :passenger do
25
32
  desc "Restart Rails app running under Phusion Passenger by touching restart.txt"
26
33
  task :restart, :roles => :app, :except => { :no_release => true } do
@@ -29,33 +36,38 @@ Capistrano::Configuration.instance(:must_exist).load do
29
36
 
30
37
  desc "Inspect Phusion Passenger's memory usage."
31
38
  task :memory, :roles => :app do
32
- run "sudo passenger-memory-stats"
39
+ run "#{try_sudo} passenger-memory-stats"
33
40
  end
34
41
 
35
42
  desc "Inspect Phusion Passenger's internal status."
36
43
  task :status, :roles => :app do
37
- run "sudo passenger-status"
44
+ run "#{try_sudo} passenger-status"
38
45
  end
39
46
 
40
47
  desc "Remove passenger config"
41
48
  task :remove, :roles => :app, :except => { :no_release => true } do
42
49
  passenger.disable
43
- run "rm #{apache_sites_available}/#{application}.conf"
50
+ run "rm #{apache_available_vhost}"
44
51
  end
45
52
 
46
53
  desc "Disable passenger config"
47
54
  task :disable, :roles => :app, :except => { :no_release => true } do
48
- run "rm #{apache_sites_enabled}/#{application}.conf"
55
+ run "rm #{apache_enabled_vhost}"
49
56
  end
50
57
 
58
+ desc "Enable passenger config"
59
+ task :enable, :roles => :app, :except => { :no_release => true } do
60
+ run "ln -nsf #{apache_available_vhost} #{apache_enabled_vhost}"
61
+ end
51
62
 
52
63
  namespace :setup do
53
64
  desc "Upload configs"
54
- task :default, :roles => :db do
65
+ task :default, :roles => :app do
55
66
  if exists?(:passenger_setup_settings)
56
- run "mkdir -p #{apache_sites_available} #{apache_sites_enabled}"
67
+ run "mkdir -p #{ passenger_template_settings.slice('sites_available', 'sites_enabled').map{|k,v| v}.join(' ') }"
57
68
  set(:recipe_settings) { passenger_template_settings }
58
- put template.render(fetch(:apache_template)), fetch(:apache_remote_file)
69
+ put template.render( passenger_template_settings['template_filename'] ), apache_available_vhost
70
+ passenger.enable
59
71
  else
60
72
  puts "[FATAL] - Passenger template settings were not found"
61
73
  abort
@@ -64,7 +76,7 @@ Capistrano::Configuration.instance(:must_exist).load do
64
76
 
65
77
  desc "Download configs"
66
78
  task :get, :roles => :db do
67
- download fetch(:apache_remote_file), File.join(local_rails_root, "configs/#{application}.conf")
79
+ download apache_available_vhost, File.join(local_rails_root, "config/#{application}.conf")
68
80
  end
69
81
  end
70
82
 
@@ -23,7 +23,7 @@ Capistrano::Configuration.instance(:must_exist).load do
23
23
  namespace :settler do
24
24
  namespace :setup do
25
25
  desc "Upload configs"
26
- task :default, :roles => :db do
26
+ task :default, :roles => :app do
27
27
  if exists?(:settler_setup_settings)
28
28
  set(:recipe_settings) { settler_template_settings }
29
29
  put template.render(fetch(:settler_template)), fetch(:settler_remote_file)
@@ -26,7 +26,7 @@ Capistrano::Configuration.instance(:must_exist).load do
26
26
  namespace :shards do
27
27
  namespace :setup do
28
28
  desc "Upload configs"
29
- task :default, :roles => :db do
29
+ task :default, :roles => :app do
30
30
  if exists?(:shards_setup_settings)
31
31
  set(:recipe_settings) do
32
32
  {
@@ -43,7 +43,7 @@ Capistrano::Configuration.instance(:must_exist).load do
43
43
 
44
44
  namespace :setup do
45
45
  desc "Upload configs"
46
- task :default, :roles => :db do
46
+ task :default, :roles => :app do
47
47
  if exists?(:thin_setup_settings)
48
48
  set(:recipe_settings) { thin_template_settings }
49
49
  put template.render(fetch(:thin_template)), fetch(:thin_remote_file)
@@ -14,7 +14,7 @@ Capistrano::Configuration.instance(:must_exist).load do
14
14
  namespace :tire do
15
15
  namespace :setup do
16
16
  desc "Upload configs"
17
- task :default, :roles => :db do
17
+ task :default, :roles => :app do
18
18
  if exists?(:tire_setup_settings)
19
19
  set :recipe_settings, fetch(:tire_setup_settings, {})
20
20
  put template.render(fetch(:tire_template)), fetch(:tire_remote_file)
@@ -75,7 +75,7 @@ Capistrano::Configuration.instance(:must_exist).load do
75
75
  # *port* 80
76
76
  namespace :setup do
77
77
  desc "Upload configs"
78
- task :default, :roles => :db do
78
+ task :default, :roles => :app do
79
79
  if exists?(:unicorn_setup_settings)
80
80
  set(:recipe_settings) { unicorn_template_settings }
81
81
  put template.render(fetch(:unicorn_template)), File.join(shared_path, 'config/unicorn.rb')
@@ -16,7 +16,7 @@ Capistrano::Configuration.instance(:must_exist).load do
16
16
  namespace :uploader do
17
17
  namespace :setup do
18
18
  desc "Upload configs"
19
- task :default, :roles => :db do
19
+ task :default, :roles => :app do
20
20
  if exists?(:uploader_setup_settings)
21
21
  set :recipe_settings, fetch(:uploader_setup_settings, {})
22
22
  put template.render(fetch(:uploader_template)), fetch(:uploader_remote_file)
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "marcosgz-cap-recipe"
6
- s.version = "0.0.5"
6
+ s.version = "0.0.6"
7
7
  s.authors = ["Marcos G. Zimmermann"]
8
8
  s.email = ["mgzmaster@gmail.com"]
9
9
  s.homepage = "https://github.com/marcosgz/capistrano-recipe"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcosgz-cap-recipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -93,4 +93,3 @@ signing_key:
93
93
  specification_version: 3
94
94
  summary: Capistrano recipe
95
95
  test_files: []
96
- has_rdoc: