Skip to content
Browse files

Initial commit to capistrano-windows-server.

  • Loading branch information...
0 parents commit b721409905a2b7412d940c3a04c55a8734e5c14a @nilbus nilbus committed
Showing with 291 additions and 0 deletions.
  1. +5 −0 .document
  2. +48 −0 .gitignore
  3. +7 −0 Gemfile
  4. +30 −0 Gemfile.lock
  5. +20 −0 LICENSE.txt
  6. +20 −0 README.rdoc
  7. +38 −0 Rakefile
  8. +1 −0 VERSION
  9. +122 −0 lib/capistrano/windows_server.rb
5 .document
@@ -0,0 +1,5 @@
+lib/**/*.rb
+bin/*
+-
+features/**/*.feature
+LICENSE.txt
48 .gitignore
@@ -0,0 +1,48 @@
+# rcov generated
+coverage
+
+# rdoc generated
+rdoc
+
+# yard generated
+doc
+.yardoc
+
+# bundler
+.bundle
+
+# jeweler generated
+pkg
+
+# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
+#
+# * Create a file at ~/.gitignore
+# * Include files you want ignored
+# * Run: git config --global core.excludesfile ~/.gitignore
+#
+# After doing this, these files will be ignored in all your git projects,
+# saving you from having to 'pollute' every project you touch with them
+#
+# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
+#
+# For MacOS:
+#
+#.DS_Store
+
+# For TextMate
+#*.tmproj
+#tmtags
+
+# For emacs:
+#*~
+#\#*
+#.\#*
+
+# For vim:
+#*.swp
+
+# For redcar:
+#.redcar
+
+# For rubinius:
+#*.rbc
7 Gemfile
@@ -0,0 +1,7 @@
+source "http://rubygems.org"
+
+gem "capistrano"
+
+group :development do
+ gem "jeweler", "~> 1.6.4"
+end
30 Gemfile.lock
@@ -0,0 +1,30 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ capistrano (2.6.0)
+ highline
+ net-scp (>= 1.0.0)
+ net-sftp (>= 2.0.0)
+ net-ssh (>= 2.0.14)
+ net-ssh-gateway (>= 1.1.0)
+ git (1.2.5)
+ highline (1.6.2)
+ jeweler (1.6.4)
+ bundler (~> 1.0)
+ git (>= 1.2.5)
+ rake
+ net-scp (1.0.4)
+ net-ssh (>= 1.99.1)
+ net-sftp (2.0.5)
+ net-ssh (>= 2.0.9)
+ net-ssh (2.1.4)
+ net-ssh-gateway (1.1.0)
+ net-ssh (>= 1.99.1)
+ rake (0.8.7)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capistrano
+ jeweler (~> 1.6.4)
20 LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2011 SciMed Solutions, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 README.rdoc
@@ -0,0 +1,20 @@
+= capistrano-windows-server
+
+Deploy Ruby on Rails applications with Capistrano to Windows servers
+
+This gem modifies capistrano recipes to allow deploys to windows machines.
+Several nuances such as the lack of symlinks make the deploy a little different, but it's better than doing it by hand.
+See the github page for instruction on how to set up Windows to get it ready for a deploy.
+
+== Contributing to capistrano-windows-server
+
+* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
+* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
+* Fork the project
+* Start a feature/bugfix branch
+* Commit and push until you are happy with your contribution
+* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
+
+== Copyright
+
+Copyright (c) 2011 SciMed Solutions, Inc. See LICENSE.txt for further details.
38 Rakefile
@@ -0,0 +1,38 @@
+# encoding: utf-8
+
+require 'rubygems'
+require 'bundler'
+begin
+ Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
+require 'rake'
+
+require 'jeweler'
+Jeweler::Tasks.new do |gem|
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
+ gem.name = "capistrano-windows-server"
+ gem.homepage = "http://github.com/nilbus/capistrano-windows-server"
+ gem.license = "MIT"
+ gem.summary = "Deploy Ruby on Rails applications with Capistrano to Windows servers"
+ gem.description = "This gem modifies capistrano recipes to allow deploys to windows machines.\nSeveral nuances such as the lack of symlinks make the deploy a little different, but it's better than doing it by hand.\nSee the github page for instruction on how to set up Windows to get it ready for a deploy."
+ gem.email = "edward.anderson@scimedsolutions.com"
+ gem.authors = ["Edward Anderson"]
+ # dependencies defined in Gemfile
+end
+Jeweler::RubygemsDotOrgTasks.new
+
+task :default => :test
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "capistrano-windows-server #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
1 VERSION
@@ -0,0 +1 @@
+0.1.0
122 lib/capistrano/windows_server.rb
@@ -0,0 +1,122 @@
+configuration = Capistrano::Configuration.respond_to?(:instance) ?
+ Capistrano::Configuration.instance(:must_exist) :
+ Capistrano.configuration(:must_exist)
+
+configuration.load do
+ set :scm, :git
+ set :deploy_via, :remote_cache
+ set :git_enable_submodules, false # Git submodules not supported on windows
+ set :shared_dir, "."
+ set :repository_cache, "current"
+ set :scm_verbose, true
+ set :use_sudo, false
+
+ namespace :deploy do
+ desc "Custom for Windows - no releases; just update git in place"
+ task :update do
+ # update_repository_cache will attempt to clean out the repository; we must prevent that with this deploy method.
+ # /bin/git below is where www.windowsgit.com's windows git/ssh installation puts the git executable.
+ run "mkdir -p '#{shared_path}/bin'"
+ run <<-RUN
+ echo 'if [ "$1" != "clean" ]; then /bin/git $*; fi' > "#{shared_path}/bin/git.exe"
+ RUN
+ alter_path_cmd = "export PATH=#{shared_path}/bin:$PATH"
+ run <<-RUN
+ if ! grep '#{alter_path_cmd}' ~/.bashrc > /dev/null; then echo '#{alter_path_cmd}' >> ~/.bashrc; fi
+ RUN
+
+ strategy.send 'update_repository_cache'
+ end
+
+ desc "On windows, this is an alias for update"
+ task :update_code do
+ update
+ end
+
+ desc <<-DESC
+ Prepares one or more servers for deployment. Before you can use any \
+ of the Capistrano deployment tasks with your project, you will need to \
+ make sure all of your servers have been prepared with `cap deploy:setup'. When \
+ you add a new server to your cluster, you can easily run the setup task \
+ on just that server by specifying the HOSTS environment variable:
+
+ $ cap HOSTS=new.server.com deploy:setup
+
+ It is safe to run this task on servers that have already been set up; it \
+ will not destroy any deployed revisions or data.
+ DESC
+ task :setup do
+ dirs = [deploy_to]
+ run "mkdir -p #{dirs.join(' ')} && chmod g+w #{dirs.join(' ')}"
+
+ if exists?(:repository_host_key)
+ run "if ! grep '#{repository_host_key}' ~/.ssh/known_hosts > /dev/null; then echo '#{repository_host_key}' >> ~/.ssh/known_hosts; fi"
+ end
+ end
+
+ # Do nothing for Windows
+ task :finalize_update do; end
+
+ # Do nothing for Windows
+ task :symlink do; end
+
+ desc "Run migrations"
+ task :migrate do
+ set :rake_cmd, "#{ruby_exe_path} -e \"require 'rubygems'; gem 'rake', '>= 0'; load Gem.bin_path('rake', 'rake', '>= 0')\""
+ run "cd #{current_path} && #{rake_cmd} db:migrate RAILS_ENV=#{rails_env}"
+ end
+
+ desc "start mongrel"
+ task :start do
+ mongrel_instances.each do |n|
+ run "net start #{mongrel_instance_prefix}#{n}"
+ end
+ end
+
+ desc "stop mongrel"
+ task :stop do
+ mongrel_instances.each do |n|
+ run "net stop #{mongrel_instance_prefix}#{n}"
+ end
+ end
+
+ desc "restart mongrel"
+ task :restart do
+ mongrel_instances.each do |n|
+ run "net stop #{mongrel_instance_prefix}#{n}"
+ run "net start #{mongrel_instance_prefix}#{n}"
+ end
+ end
+
+ namespace :mongrel do
+ desc "create mongrel services"
+ task :setup do
+ mongrel_instances.each do |n|
+ run "cd #{current_path} && #{mongrel_cmd} service::install -e #{rails_env} -N #{mongrel_instance_prefix}#{n} -p #{base_port + n - mongrel_instances.first}"
+ run %Q(sc.exe config "#{mongrel_instance_prefix}#{n}" start= auto)
+ end
+ end
+
+ desc "remove mongrel services"
+ task :remove do
+ set :mongrel_cmd, "#{ruby_exe_path} -e \"require 'rubygems'; gem 'mongrel', '>= 0'; load Gem.bin_path('mongrel', 'mongrel_rails', '>= 0')\""
+ mongrel_instances.each do |n|
+ run "#{mongrel_cmd} service::remove -N #{mongrel_instance_prefix}#{n}"
+ end
+ end
+
+ end
+
+ end
+
+ desc "Run a rake command in CMD"
+ task :rake do
+ raise "Specify the command with CMD='some:task with_arguments'" unless ENV['CMD']
+ set :rake_cmd, "#{ruby_exe_path} -e \"require 'rubygems'; gem 'rake', '>= 0'; load Gem.bin_path('rake', 'rake', '>= 0')\""
+ run "cd #{current_path} && #{rake_cmd} #{ENV['CMD']} RAILS_ENV=#{rails_env}"
+ end
+
+ after 'deploy:setup', 'deploy:update_code'
+ after 'deploy:setup', 'deploy:mongrel:setup'
+
+end

0 comments on commit b721409

Please sign in to comment.
Something went wrong with that request. Please try again.