Skip to content
Browse files

renamed project

  • Loading branch information...
1 parent 7a8e021 commit 451a3e4549eed85970b268826b4ad0439706aa0a Michael Schiller committed Oct 17, 2012
Showing with 178 additions and 22 deletions.
  1. +1 −1 Gemfile
  2. +3 −3 ms_deploy.gemspec → caploy.gemspec
  3. +1 −0 lib/caploy.rb
  4. 0 lib/{ms_deploy → caploy}/recipes/airbrake.rb
  5. 0 lib/{ms_deploy → caploy}/recipes/assets.rb
  6. 0 lib/{ms_deploy → caploy}/recipes/bundler.rb
  7. +14 −0 lib/{ms_deploy → caploy}/recipes/database.rb
  8. 0 lib/{ms_deploy → caploy}/recipes/defaults.rb
  9. 0 lib/{ms_deploy → caploy}/recipes/info.rb
  10. 0 lib/{ms_deploy → caploy}/recipes/monitoring.rb
  11. +1 −1 lib/{ms_deploy → caploy}/recipes/nginx.rb
  12. 0 lib/{ms_deploy → caploy}/recipes/paperclip.rb
  13. 0 lib/{ms_deploy → caploy}/recipes/passenger.rb
  14. 0 lib/{ms_deploy → caploy}/recipes/puma.rb
  15. 0 lib/{ms_deploy → caploy}/recipes/rbenv.rb
  16. 0 lib/{ms_deploy → caploy}/recipes/redis.rb
  17. 0 lib/{ms_deploy → caploy}/recipes/rvm.rb
  18. 0 lib/{ms_deploy → caploy}/recipes/seeding.rb
  19. 0 lib/{ms_deploy → caploy}/recipes/setup.rb
  20. 0 lib/{ms_deploy → caploy}/recipes/symlink.rb
  21. 0 lib/{ms_deploy → caploy}/recipes/unicorn.rb
  22. +90 −0 lib/caploy/recipes/unicorn_bluepill.rb
  23. 0 lib/{ms_deploy → caploy}/recipes/whenever.rb
  24. 0 lib/{ms_deploy → caploy}/render.rb
  25. +9 −0 lib/caploy/templates/bluepill/init.erb
  26. +43 −0 lib/caploy/templates/bluepill/unicorn_config.rb.erb
  27. 0 lib/{ms_deploy/templates → caploy/templates/nginx}/vhost.erb
  28. 0 lib/{ms_deploy → caploy}/templates/unicorn/unicorn.rb.erb
  29. +3 −0 lib/caploy/version.rb
  30. +13 −13 lib/examples/deploy.rb
  31. +0 −1 lib/ms_deploy.rb
  32. +0 −3 lib/ms_deploy/version.rb
View
2 Gemfile
@@ -1,4 +1,4 @@
source 'http://rubygems.org'
-# Specify your gem's dependencies in ms_deploy.gemspec
+# Specify your gem's dependencies in caploy.gemspec
gemspec
View
6 ms_deploy.gemspec → caploy.gemspec
@@ -6,12 +6,12 @@ Gem::Specification.new do |gem|
gem.email = ["michael.schiller@gmx.de"]
gem.description = %q{capistrano deployment task for my projects}
gem.summary = %q{capistrano deployment task for my projects}
- gem.homepage = "https://github.com/mschiller/ms_deploy"
+ gem.homepage = "https://github.com/mschiller/caploy"
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- gem.name = "ms_deploy"
+ gem.name = "caploy"
gem.require_paths = ["lib"]
gem.add_dependency('gemcutter')
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
gem.add_dependency('rvm-capistrano', '>= 1.2.2')
gem.add_dependency('erubis')
- gem.version = MsDeploy::VERSION
+ gem.version = Caploy::VERSION
end
View
1 lib/caploy.rb
@@ -0,0 +1 @@
+require "caploy/version"
View
0 lib/ms_deploy/recipes/airbrake.rb → lib/caploy/recipes/airbrake.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/assets.rb → lib/caploy/recipes/assets.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/bundler.rb → lib/caploy/recipes/bundler.rb
File renamed without changes.
View
14 lib/ms_deploy/recipes/database.rb → lib/caploy/recipes/database.rb
@@ -41,4 +41,18 @@
end
end
end
+
+ namespace :deploy do
+ after 'deploy:make_symlinks', 'deploy:dynamic_migrations' if fetch(:dynamic_migration, false)
+
+ task :dynamic_migrations do
+ from = source.next_revision(current_revision)
+ if capture("cd #{latest_release} && #{source.local.log(from)} db/migrate | wc -l").to_i > 0
+ run "cd #{current_release} && RAILS_ENV=#{rails_env} bundle exec rake db:migrate"
+ logger.info "New migrations added - running migrations."
+ else
+ logger.info "Skipping migrations - there are not any new."
+ end
+ end
+ end
end
View
0 lib/ms_deploy/recipes/defaults.rb → lib/caploy/recipes/defaults.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/info.rb → lib/caploy/recipes/info.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/monitoring.rb → lib/caploy/recipes/monitoring.rb
File renamed without changes.
View
2 lib/ms_deploy/recipes/nginx.rb → lib/caploy/recipes/nginx.rb
@@ -29,7 +29,7 @@
task :setup, :roles => :web do
protocol = fetch(:protocol, nil).to_s
- template_path = File.expand_path('../../templates/vhost.erb', __FILE__)
+ template_path = File.expand_path('../../templates/nginx/vhost.erb', __FILE__)
vars = {
'application' => application,
'project_root' => deploy_to + '/current',
View
0 lib/ms_deploy/recipes/paperclip.rb → lib/caploy/recipes/paperclip.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/passenger.rb → lib/caploy/recipes/passenger.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/puma.rb → lib/caploy/recipes/puma.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/rbenv.rb → lib/caploy/recipes/rbenv.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/redis.rb → lib/caploy/recipes/redis.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/rvm.rb → lib/caploy/recipes/rvm.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/seeding.rb → lib/caploy/recipes/seeding.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/setup.rb → lib/caploy/recipes/setup.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/symlink.rb → lib/caploy/recipes/symlink.rb
File renamed without changes.
View
0 lib/ms_deploy/recipes/unicorn.rb → lib/caploy/recipes/unicorn.rb
File renamed without changes.
View
90 lib/caploy/recipes/unicorn_bluepill.rb
@@ -0,0 +1,90 @@
+
+#
+# sudoers:
+# %deploy ALL=(ALL) NOPASSWD: /usr/local/bin/bluepill, /sbin/start my_app_bluepill , /sbin/stop my_app_bluepill
+# sudo chown root:root deploy_conf
+# sudo chmod 0440 deploy_conf
+# => /etc/sudoers.d
+#
+Capistrano::Configuration.instance.load do
+
+ namespace :deploy do
+
+ task :start, :roles => :app, :except => { :no_release => true } do
+ sudo 'start bluepill_conf'
+ end
+
+ task :stop, :roles => :app, :except => { :no_release => true } do
+ sudo "bluepill stop"
+ sudo "stop bluepill_conf"
+ end
+
+ task :restart, :roles => :app, :except => { :no_release => true } do
+ sudo "bluepill restart unicorn"
+ end
+
+ #desc "Restart Resque Workers"
+ #task :restart_workers do
+ # sudo "bluepill stop resque"
+ # sudo "bluepill start resque"
+ #end
+ #
+ #desc "Start Resque Workers"
+ #task :start_workers do
+ # sudo "bluepill start resque"
+ #end
+ #
+ #desc "Stop Resque Workers"
+ #task :stop_workers do
+ # sudo "bluepill stop resque"
+ #end
+
+ end
+
+ namespace :bluepill do
+ desc "Prints bluepills monitored processes statuses"
+ task :status, :roles => [:app] do
+ sudo "bluepill status"
+ end
+
+ desc "Setup blupill config"
+ task :setup, :roles => [:app] do
+ setup_init
+ setup_config
+ end
+
+ task :setup_init do
+ template_path = File.expand_path('../../templates/bluepill/init.erb', __FILE__)
+ vars = {
+ 'application' => application,
+ 'config_path' => fetch(:bluepill_config_path, "#{shared_path}/config/bluepill_config.pill")
+ }
+
+ config_path = "#{shared_path}/config/bluepill_init.conf"
+
+ put(render_erb_template(template_path, vars), config_path)
+ sudo "rm -f /etc/init/bluepill_#{application}_#{stage}.conf"
+ sudo "ln -s #{config_path} /etc/init/bluepill_#{application}_#{stage}.conf"
+ end
+
+ task :setup_config do
+ template_path = File.expand_path('../../templates/bluepill/default_config.rb.erb', __FILE__)
+ log_file = "#{latest_release}/log/bluepill.log"
+ unicorn_config_path = "#{shared_path}/config/unicorn/#{stage}.rb"
+ vars = {
+ 'application' => application,
+ 'stage' => stage,
+ 'log_file' => log_file,
+ 'unicorn_config_path' => unicorn_config_path
+ }
+
+ config_path = fetch(:bluepill_config_path, "#{shared_path}/config/bluepill_config.pill")
+ put(render_erb_template(template_path, vars), config_path)
+
+ end
+ end
+
+ #after "deploy:restart", "deploy:restart_workers"
+ after "deploy:setup", "bluepill:setup"
+
+end
View
0 lib/ms_deploy/recipes/whenever.rb → lib/caploy/recipes/whenever.rb
File renamed without changes.
View
0 lib/ms_deploy/render.rb → lib/caploy/render.rb
File renamed without changes.
View
9 lib/caploy/templates/bluepill/init.erb
@@ -0,0 +1,9 @@
+description "<%= application %>"
+
+start on runlevel [2]
+stop on runlevel [016]
+
+expect daemon
+exec bluepill load <%= config_path %>
+
+respawn
View
43 lib/caploy/templates/bluepill/unicorn_config.rb.erb
@@ -0,0 +1,43 @@
+ENV["RAILS_ENV"] = "<%= stage %>"
+
+Bluepill.application("<%= application %>-<%= stage %>", :log_file => '<%= log_file %>') do |app|
+
+ app.process("unicorn") do |process|
+ process.pid_file = '<%= unicorn_config_path %>'
+ process.working_dir = '/var/my_app/current'
+
+ process.start_command = "/usr/local/bin/bundle exec unicorn -c /var/my_app/current/config/unicorn.rb -E staging -D"
+ process.stop_command = "kill -QUIT {{PID}}"
+ process.restart_command = "kill -USR2 {{PID}}"
+
+ process.uid = process.gid = 'deploy'
+
+ process.start_grace_time = 30.seconds
+ process.stop_grace_time = 30.seconds
+ process.restart_grace_time = 30.seconds
+
+
+ process.monitor_children do |child_process|
+ child_process.stop_command = "kill -QUIT {{PID}}"
+
+ child_process.checks :mem_usage, :every => 30.seconds, :below => 200.megabytes, :times => [3, 4], :fires => :stop
+ child_process.checks :cpu_usage, :every => 30.seconds, :below => 40, :times => [3, 4], :fires => :stop
+ end
+ end
+
+ 2.times do |i|
+ app.process("resque-#{i}") do |process|
+ process.working_dir = '/var/my_app/current'
+ process.group = "resque"
+ process.start_command = "/usr/local/bin/bundle exec rake resque:work"
+ process.pid_file = "/var/my_app/shared/pids/my_app-resque-#{i}.pid"
+ process.stop_command = "kill -QUIT {{PID}}"
+ process.daemonize = true
+
+ process.start_grace_time = 30.seconds
+ process.stop_grace_time = 30.seconds
+ process.uid = process.gid = 'deploy'
+
+ end
+ end
+end
View
0 lib/ms_deploy/templates/vhost.erb → lib/caploy/templates/nginx/vhost.erb
File renamed without changes.
View
0 ...s_deploy/templates/unicorn/unicorn.rb.erb → lib/caploy/templates/unicorn/unicorn.rb.erb
File renamed without changes.
View
3 lib/caploy/version.rb
@@ -0,0 +1,3 @@
+module Caploy
+ VERSION = "0.1.0"
+end
View
26 lib/examples/deploy.rb
@@ -58,16 +58,16 @@
}
}
-require 'ms_deploy/recipes/defaults'
-
-require 'ms_deploy/recipes/rbenv'
-require 'ms_deploy/recipes/assets'
-require 'ms_deploy/recipes/nginx'
-require 'ms_deploy/recipes/bundler'
-require 'ms_deploy/recipes/symlink'
-require 'ms_deploy/recipes/unicorn'
-require 'ms_deploy/recipes/setup'
-require 'ms_deploy/recipes/monitoring'
-require 'ms_deploy/recipes/seeding'
-#require 'ms_deploy/recipes/paperclip'
-#require 'ms_deploy/recipes/airbrake'
+require 'caploy/recipes/defaults'
+
+require 'caploy/recipes/rbenv'
+require 'caploy/recipes/assets'
+require 'caploy/recipes/nginx'
+require 'caploy/recipes/bundler'
+require 'caploy/recipes/symlink'
+require 'caploy/recipes/unicorn'
+require 'caploy/recipes/setup'
+require 'caploy/recipes/monitoring'
+require 'caploy/recipes/seeding'
+#require 'caploy/recipes/paperclip'
+#require 'caploy/recipes/airbrake'
View
1 lib/ms_deploy.rb
@@ -1 +0,0 @@
-require "ms_deploy/version"
View
3 lib/ms_deploy/version.rb
@@ -1,3 +0,0 @@
-module MsDeploy
- VERSION = "0.3.6"
-end

0 comments on commit 451a3e4

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