capistrano-windows-server 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- capistrano (2.9.0)
4
+ capistrano (2.11.2)
5
5
  highline
6
6
  net-scp (>= 1.0.0)
7
7
  net-sftp (>= 2.0.0)
8
8
  net-ssh (>= 2.0.14)
9
9
  net-ssh-gateway (>= 1.1.0)
10
10
  git (1.2.5)
11
- highline (1.6.9)
11
+ highline (1.6.11)
12
12
  jeweler (1.6.4)
13
13
  bundler (~> 1.0)
14
14
  git (>= 1.2.5)
data/README.md CHANGED
@@ -99,12 +99,12 @@ There are a few configuration values that need to be set in your deploy.rb, in a
99
99
 
100
100
  set :rails_env, 'production'
101
101
  set :user, 'git'
102
- set :deploy_to, "/cygdrive/c/rails_apps/#{application}" # Deploy to C:\rails_apps\#{application}
103
- set :mongrel_instances, (1..3) # Create 3 mongrel instances
104
- set :mongrel_instance_prefix, 'mongrel_' # named mongrel_{1..3}
105
- set :base_port, 8000 # on ports 8000, 8001, 8002
106
-
107
- set :ruby_exe_path, '/cygdrive/c/ruby/bin/ruby' # This should be set to the location where Ruby is installed.
102
+ set :deploy_to, "/cygdrive/c/rails_apps/#{application}" # Deploy to C:\rails_apps\#{application}
103
+ set :mongrel_instances, (1..3) # Create 3 mongrel instances
104
+ set :mongrel_instance_prefix, 'mongrel_' # named mongrel_{1..3}
105
+ set :base_port, 8000 # on ports 8000, 8001, 8002
106
+ set :bundler_git_command, '/cygdrive/c/RailsInstaller/Git/bin/git.exe' # Specify the remote location of a Windows installation of git
107
+ # Required only when your Gemfile pulls gems from a git repository
108
108
 
109
109
  Your final config/deploy.rb might look something like this:
110
110
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.6
1
+ 0.5.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{capistrano-windows-server}
8
- s.version = "0.4.6"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edward Anderson"]
12
- s.date = %q{2012-02-20}
12
+ s.date = %q{2012-02-24}
13
13
  s.description = %q{This gem modifies capistrano recipes to allow deploys to windows machines.
14
14
  Several nuances such as the lack of symlinks make the deploy a little different, but it's better than doing it by hand.
15
15
  See the github page for instruction on how to set up Windows to get it ready for a deploy.}
@@ -27,6 +27,7 @@ See the github page for instruction on how to set up Windows to get it ready for
27
27
  "Rakefile",
28
28
  "VERSION",
29
29
  "capistrano-windows-server.gemspec",
30
+ "lib/capistrano-windows-server.rb",
30
31
  "lib/capistrano/ext/windows_server.rb"
31
32
  ]
32
33
  s.homepage = %q{http://github.com/nilbus/capistrano-windows-server}
File without changes
@@ -10,6 +10,7 @@ configuration.load do
10
10
  set :repository_cache, "current"
11
11
  set :scm_verbose, true
12
12
  set :use_sudo, false
13
+ set :default_shell, false
13
14
 
14
15
  def strip_cygdrive(path)
15
16
  path.sub /\/cygdrive\/([c-z])\//, '\1:/'
@@ -18,28 +19,31 @@ configuration.load do
18
19
  def latest_release
19
20
  strip_cygdrive current_path
20
21
  end
21
-
22
- # We can't run ruby commands directly, because the rake script searches for ruby based on windows paths that aren't valid in this environment
23
- def ruby_cmd(cmd, gem_name=cmd)
24
- %Q(PATH="#{File.dirname ruby_exe_path}:$PATH" #{ruby_exe_path} -e "require 'rubygems'; gem '#{gem_name}', '>= 0'; load Gem.bin_path('#{gem_name}', '#{cmd}', '>= 0')")
22
+
23
+ def system_path
24
+ return @system_path if @system_path
25
+ run 'echo "/bin:/usr/bin:$PATH"' do |channel, stream, data|
26
+ return @system_path = data.strip # Probably not compatible with multiple run targets with different PATHs
27
+ end
25
28
  end
26
29
 
27
- def run_ruby_cmd(cmd, args='', gem_name=cmd)
28
- run "cd #{current_path} && #{ruby_cmd cmd, gem_name} #{args}"
30
+ task :path do
31
+ puts system_path.inspect
29
32
  end
30
-
31
- def bundle_exec(cmd, args='', gem_name=cmd)
33
+
34
+ def run_ruby_cmd(cmd)
35
+ bundler_git_path = "#{File.dirname(bundler_git_command)}:" rescue nil
36
+ run "cd #{current_path} && PATH='#{bundler_git_path}#{system_path}' ruby -S #{cmd}"
37
+ end
38
+
39
+ def bundle_exec(cmd)
32
40
  if gemfile_present?
33
- run_ruby_cmd 'bundle', "exec #{cmd} #{args}", 'bundler'
41
+ run_ruby_cmd "bundle exec #{cmd}"
34
42
  else
35
- run_ruby_cmd cmd, args, gem_name
43
+ run_ruby_cmd cmd
36
44
  end
37
45
  end
38
46
 
39
- def rubygems_cmd
40
- "PATH=\"#{File.dirname ruby_exe_path}:$PATH\" #{ruby_exe_path} -e \"require 'rubygems';require 'rubygems/gem_runner';require 'rubygems/exceptions';Gem::GemRunner.new.run ARGV.clone\""
41
- end
42
-
43
47
  def application_server
44
48
  app_server rescue :mongrel
45
49
  end
@@ -53,17 +57,31 @@ configuration.load do
53
57
  task :update_code do
54
58
  # update_repository_cache will attempt to clean out the repository; we must prevent that.
55
59
  # /bin/git below is where www.windowsgit.com's windows git/ssh installation puts the git executable.
56
- # This creates a git proxy that goes in $PATH before /bin, which will filter out any `git clean` commands.
57
- run "mkdir -p '#{shared_path}/bin'"
60
+ # This creates a git wrapper that goes in $PATH before /bin, which will filter out any `git clean` commands.
61
+ run "/bin/mkdir -p '#{shared_path}/bin'"
58
62
  run <<-RUN
59
63
  echo 'if [ "$1" != "clean" ]; then /bin/git $*; fi' > "#{shared_path}/bin/git.exe"
60
64
  RUN
61
65
  alter_path_cmd = "export PATH=#{shared_path}/bin:$PATH # Required for capistrano-windows-server"
62
66
  run <<-RUN
63
- if ! grep '#{alter_path_cmd}' ~/.bashrc > /dev/null; then echo '#{alter_path_cmd}' >> ~/.bashrc; fi
67
+ if ! /bin/grep '#{alter_path_cmd}' ~/.bashrc > /dev/null; then echo '#{alter_path_cmd}' >> ~/.bashrc; fi
64
68
  RUN
65
69
 
66
- strategy.send 'update_repository_cache'
70
+ continue = true
71
+ while continue
72
+ begin
73
+ strategy.send 'update_repository_cache'
74
+ continue = false
75
+ rescue
76
+ puts "Failed to check out git. If the error was 'fatal: The remote end hung up unexpectedly', this is due to a cygwin ssh bug."
77
+ puts "It often works to just try again repeatedly (a lot! 30+ times for an initial clone - it's like playing the lottery :-)"
78
+ @try_again_response ||= Capistrano::CLI.ui.ask("Keep trying? [Y/n]: ").to_s.chomp
79
+ unless @try_again_response.empty? || @try_again_response.downcase == 'y'
80
+ continue = false
81
+ raise $!
82
+ end
83
+ end
84
+ end
67
85
  finalize_update
68
86
  end
69
87
 
@@ -81,10 +99,10 @@ configuration.load do
81
99
  DESC
82
100
  task :setup do
83
101
  dirs = [deploy_to]
84
- run "mkdir -p #{dirs.join(' ')} && chmod g+w #{dirs.join(' ')}"
102
+ run "/bin/mkdir -p #{dirs.join(' ')} && /bin/chmod g+w #{dirs.join(' ')}"
85
103
 
86
104
  if exists?(:repository_host_key)
87
- run "if ! grep '#{repository_host_key}' ~/.ssh/known_hosts > /dev/null; then echo '#{repository_host_key}' >> ~/.ssh/known_hosts; fi"
105
+ run "if ! /bin/grep '#{repository_host_key}' ~/.ssh/known_hosts > /dev/null; then echo '#{repository_host_key}' >> ~/.ssh/known_hosts; fi"
88
106
  end
89
107
  end
90
108
 
@@ -98,9 +116,9 @@ configuration.load do
98
116
  end
99
117
  end
100
118
 
101
- desc "Run pending migrations"
119
+ desc "Run pending migrations. Override the default rails environment with RAILS_ENV"
102
120
  task :migrate do
103
- bundle_exec 'rake', "db:migrate RAILS_ENV=#{rails_env}"
121
+ bundle_exec "rake db:migrate RAILS_ENV=#{ENV['RAILS_ENV'] || rails_env}"
104
122
  end
105
123
 
106
124
  desc "Start mongrel"
@@ -133,8 +151,8 @@ configuration.load do
133
151
  task :setup do
134
152
  return unless application_server == :mongrel
135
153
  mongrel_instances.each do |n|
136
- run "mkdir -p #{current_path}/{tmp,log}" # These are often not under version control, but their absence keeps mongrel from recognizing the rails app
137
- bundle_exec 'mongrel_rails', "service::install -e #{rails_env} -N #{mongrel_instance_prefix}#{n} -p #{base_port + n - mongrel_instances.first}; true", 'mongrel'
154
+ run "/bin/mkdir -p #{current_path}/{tmp,log}" # These are often not under version control, but their absence keeps mongrel from recognizing the rails app
155
+ bundle_exec "mongrel_rails service::install -e #{rails_env} -N #{mongrel_instance_prefix}#{n} -p #{base_port + n - mongrel_instances.first}; true"
138
156
  run %Q(sc.exe config "#{mongrel_instance_prefix}#{n}" start= auto type= interact type= own; true)
139
157
  end
140
158
  end
@@ -142,47 +160,42 @@ configuration.load do
142
160
  desc "Remove mongrel services"
143
161
  task :remove do
144
162
  mongrel_instances.each do |n|
145
- bundle_exec 'mongrel_rails', "service::remove -N #{mongrel_instance_prefix}#{n}; true", 'mongrel'
163
+ bundle_exec "mongrel_rails service::remove -N #{mongrel_instance_prefix}#{n}; true"
146
164
  end
147
165
  end
148
-
149
166
  end
150
-
151
167
  end
152
168
 
153
- desc "Run a rake command in COMMAND"
169
+ desc "Run a rake command in COMMAND. RAILS_ENV for the configured environment will be included; it can be overridden by setting RAILS_ENV"
154
170
  task :rake do
155
171
  raise "Specify the command with COMMAND='some:task with_arguments'" unless ENV['COMMAND']
156
- bundle_exec 'rake', "#{ENV['COMMAND']} RAILS_ENV=#{rails_env}"
172
+ bundle_exec "rake #{ENV['COMMAND']} RAILS_ENV=#{ENV['RAILS_ENV'] || rails_env}"
157
173
  end
158
174
 
159
175
  desc "Run a rubygems (gem) command in COMMAND"
160
176
  task :rubygems do
161
177
  raise "Specify the command with COMMAND='install rails'" unless ENV['COMMAND']
162
- run "cd #{current_path} && #{rubygems_cmd} #{ENV['COMMAND']}"
178
+ bundle_exec "gem #{ENV['COMMAND']}"
163
179
  end
164
180
 
165
- namespace :git do
166
- desc "Run a git command in COMMAND"
167
- task :execute do
168
- raise "Specify the command with COMMAND. eg: COMMAND='diff HEAD^^'" unless ENV['COMMAND']
169
- run "cd #{current_path} && git #{ENV['COMMAND']}"
170
- end
181
+ desc "Run a git command in COMMAND"
182
+ task :git do
183
+ raise "Specify the command with COMMAND. eg: COMMAND='diff HEAD^^'" unless ENV['COMMAND']
184
+ run "cd #{current_path} && /bin/git #{ENV['COMMAND']}"
171
185
  end
172
186
 
173
187
  namespace :bundle do
174
- desc "Install gems with bundler"
175
- task :install do
188
+ desc "Execute a COMMAND with bundle exec"
189
+ task :default do
176
190
  raise "No Gemfile detected" unless gemfile_present?
177
- run_ruby_cmd 'bundle', "install --without test development --path #{strip_cygdrive deploy_to}/bundle", 'bundler'
191
+ raise "Specify the command with COMMAND. eg: COMMAND='rake db:migrate'" unless ENV['COMMAND']
192
+ bundle_exec ENV['COMMAND']
178
193
  end
179
194
 
180
- desc "Execute a COMMAND with bundle exec"
181
- task :execute do
195
+ desc "Install gems with bundler"
196
+ task :install do
182
197
  raise "No Gemfile detected" unless gemfile_present?
183
- raise "Specify the command with COMMAND. eg: COMMAND='rake db:migrate'" unless ENV['COMMAND']
184
- args = ENV['COMMAND'].split
185
- bundle_exec args.shift, args.join(' ')
198
+ run_ruby_cmd "bundle install --without test development --path ../bundle"
186
199
  end
187
200
  end
188
201
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-windows-server
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 6
10
- version: 0.4.6
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Edward Anderson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-20 00:00:00 -05:00
18
+ date: 2012-02-24 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -69,6 +69,7 @@ files:
69
69
  - Rakefile
70
70
  - VERSION
71
71
  - capistrano-windows-server.gemspec
72
+ - lib/capistrano-windows-server.rb
72
73
  - lib/capistrano/ext/windows_server.rb
73
74
  has_rdoc: true
74
75
  homepage: http://github.com/nilbus/capistrano-windows-server