Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

renamed project

  • Loading branch information...
commit 451a3e4549eed85970b268826b4ad0439706aa0a 1 parent 7a8e021
Michael Schiller authored

Showing 32 changed files with 178 additions and 22 deletions. Show diff stats Hide diff stats

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

0 comments on commit 451a3e4

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