capistrano-runit 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,8 @@
1
+ === 1.1.0 2011-10-23
2
+
3
+ * Bugfixes.
4
+ * Added Resque recipe.
5
+
6
+ === 1.0
7
+
8
+ * Initial release.
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "capistrano-runit"
3
- s.version = "1.0.0"
3
+ s.version = "1.1.0"
4
4
  s.summary = "Useful deployment recipes."
5
- s.homepage = "http://github.com/antage/capistrano-runit"
5
+ s.homepage = "https://github.com/antage/capistrano-runit"
6
6
  s.author = "Anton Ageev"
7
7
  s.email = "antage@gmail.com"
8
8
  s.files = `git ls-files`.split
@@ -1,3 +1,4 @@
1
1
  require "capistrano-runit/recipes/base"
2
2
  require "capistrano-runit/recipes/unicorn"
3
3
  require "capistrano-runit/recipes/delayed_job"
4
+ require "capistrano-runit/recipes/resque"
@@ -1,6 +1,7 @@
1
1
  Capistrano::Configuration.instance(true).load do
2
2
  _cset :runit_delayed_job_service_name, "delayed_job"
3
3
  _cset :runit_delayed_job_template, File.expand_path(File.join(File.dirname(__FILE__), "../templates/run-delayed_job.erb"))
4
+ _cset :runit_delayed_job_environment, defer { { "RAILS_ENV" => fetch(:rails_env) } }
4
5
  _cset :runit_delayed_job_command, "./script/delayed_job"
5
6
 
6
7
  namespace :runit do
@@ -27,6 +28,16 @@ Capistrano::Configuration.instance(true).load do
27
28
  run "[ ! -h #{runit_dir}/enabled/#{runit_delayed_job_service_name} ] || sv stop #{runit_dir}/enabled/#{runit_delayed_job_service_name}/ && rm -f #{runit_dir}/enabled/#{runit_delayed_job_service_name}"
28
29
  end
29
30
 
31
+ desc "Start delayed_job runit-service"
32
+ task :start, :roles => :app do
33
+ run "[ ! -h #{runit_dir}/enabled/#{runit_delayed_job_service_name} ] || sv start #{runit_dir}/enabled/#{runit_delayed_job_service_name}/"
34
+ end
35
+
36
+ desc "Stop delayed_job runit-service"
37
+ task :stop, :roles => :app do
38
+ run "[ ! -h #{runit_dir}/enabled/#{runit_delayed_job_service_name} ] || sv stop #{runit_dir}/enabled/#{runit_delayed_job_service_name}/"
39
+ end
40
+
30
41
  desc "Restart delayed_job runit-service"
31
42
  task :restart, :roles => :app do
32
43
  run "[ ! -h #{runit_dir}/enabled/#{runit_delayed_job_service_name} ] || sv restart #{runit_dir}/enabled/#{runit_delayed_job_service_name}/"
@@ -0,0 +1,48 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+ _cset :runit_resque_service_name, "resque"
3
+ _cset :runit_resque_template, File.expand_path(File.join(File.dirname(__FILE__), "../templates/run-resque.erb"))
4
+ _cset :runit_resque_environment, defer { { "RAILS_ENV" => fetch(:rails_env) } }
5
+ _cset :runit_resque_command, defer { "#{rake} environment resque:work" }
6
+ _cset :runit_resque_queue, "*"
7
+
8
+ namespace :runit do
9
+ namespace :resque do
10
+ desc "Setup resque runit-service"
11
+ task :setup, :roles => :app do
12
+ run "[ -d #{runit_dir}/available/#{runit_resque_service_name} ] || mkdir -p #{runit_dir}/available/#{runit_resque_service_name}"
13
+ template = File.read(runit_resque_template)
14
+ erb_template = ERB.new(template)
15
+ servers = find_servers_for_task(current_task)
16
+ servers.each do |server|
17
+ put erb_template.result(binding), "#{runit_dir}/available/#{runit_resque_service_name}/run", :mode => 0755, :hosts => server.host
18
+ end
19
+ find_and_execute_task "runit:resque:enable"
20
+ end
21
+
22
+ desc "Enable resque runit-service"
23
+ task :enable, :roles => :app do
24
+ run "cd #{runit_dir}/enabled && [ -h ./#{runit_resque_service_name} ] || ln -sf ../available/#{runit_resque_service_name} ."
25
+ end
26
+
27
+ desc "Disable resque runit-service"
28
+ task :disable, :roles => :app do
29
+ run "[ ! -h #{runit_dir}/enabled/#{runit_resque_service_name} ] || sv stop #{runit_dir}/enabled/#{runit_resque_service_name}/ && rm -f #{runit_dir}/enabled/#{runit_resque_service_name}"
30
+ end
31
+
32
+ desc "Start resque runit-service"
33
+ task :start, :roles => :app do
34
+ run "[ ! -h #{runit_dir}/enabled/#{runit_resque_service_name} ] || sv start #{runit_dir}/enabled/#{runit_resque_service_name}/"
35
+ end
36
+
37
+ desc "Stop resque runit-service"
38
+ task :stop, :roles => :app do
39
+ run "[ ! -h #{runit_dir}/enabled/#{runit_resque_service_name} ] || sv stop #{runit_dir}/enabled/#{runit_resque_service_name}/"
40
+ end
41
+
42
+ desc "Restart resque runit-service"
43
+ task :restart, :roles => :app do
44
+ run "[ ! -h #{runit_dir}/enabled/#{runit_resque_service_name} ] || sv restart #{runit_dir}/enabled/#{runit_resque_service_name}/"
45
+ end
46
+ end
47
+ end
48
+ end
@@ -49,10 +49,25 @@ Capistrano::Configuration.instance(true).load do
49
49
  run "[ ! -h #{runit_dir}/enabled/#{runit_unicorn_service_name} ] || sv stop #{runit_dir}/enabled/#{runit_unicorn_service_name}/ && rm -f #{runit_dir}/enabled/#{runit_unicorn_service_name}"
50
50
  end
51
51
 
52
+ desc "Start Unicorn runit-service"
53
+ task :start, :roles => :app do
54
+ run "[ ! -h #{runit_dir}/enabled/#{runit_unicorn_service_name} ] || sv start #{runit_dir}/enabled/#{runit_unicorn_service_name}/"
55
+ end
56
+
57
+ desc "Stop Unicorn runit-service"
58
+ task :stop, :roles => :app do
59
+ run "[ ! -h #{runit_dir}/enabled/#{runit_unicorn_service_name} ] || sv stop #{runit_dir}/enabled/#{runit_unicorn_service_name}/"
60
+ end
61
+
52
62
  desc "Restart Unicorn runit-service"
53
63
  task :restart, :roles => :app do
54
64
  run "[ ! -h #{runit_dir}/enabled/#{runit_unicorn_service_name} ] || sv restart #{runit_dir}/enabled/#{runit_unicorn_service_name}/"
55
65
  end
66
+
67
+ desc "Zerodown restart Unicorn runit-service"
68
+ task :zerodown_restart, :roles => :app do
69
+ run "[ ! -h #{runit_dir}/enabled/#{runit_unicorn_service_name} ] || sv hup #{runit_dir}/enabled/#{runit_unicorn_service_name}/"
70
+ end
56
71
  end
57
72
  end
58
73
  end
@@ -1,3 +1,3 @@
1
1
  #!/bin/bash
2
2
  cd <%= current_path %>
3
- <%= runit_delayed_job_command %> run
3
+ <%= runit_delayed_job_environment.map { |k, v| "#{k}='#{v}'" }.join(" ") %> exec <%= runit_delayed_job_command %> run
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ cd <%= current_path %>
3
+ QUEUE=<%= runit_resque_queue || "*" %> <%= runit_resque_environment.map { |k,v| "#{k}='#{v}'" }.join(" ") %> exec <%= runit_resque_command %>
@@ -42,6 +42,9 @@ if GC.respond_to?(:copy_on_write_friendly=)
42
42
  GC.copy_on_write_friendly = true
43
43
  end
44
44
 
45
+ before_exec do |server|
46
+ ENV["BUNDLE_GEMFILE"] = "$APP_DIR/Gemfile" if File.exists?("$APP_DIR/Gemfile")
47
+ end
45
48
 
46
49
  before_fork do |server, worker|
47
50
  # the following is highly recomended for Rails + "preload_app true"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-runit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anton Ageev
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-15 00:00:00 +04:00
18
+ date: 2011-10-23 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -45,16 +45,19 @@ extra_rdoc_files: []
45
45
  files:
46
46
  - .gitignore
47
47
  - Gemfile
48
+ - History.txt
48
49
  - README.markdown
49
50
  - capistrano-runit.gemspec
50
51
  - lib/capistrano-runit/recipes.rb
51
52
  - lib/capistrano-runit/recipes/base.rb
52
53
  - lib/capistrano-runit/recipes/delayed_job.rb
54
+ - lib/capistrano-runit/recipes/resque.rb
53
55
  - lib/capistrano-runit/recipes/unicorn.rb
54
56
  - lib/capistrano-runit/templates/run-delayed_job.erb
57
+ - lib/capistrano-runit/templates/run-resque.erb
55
58
  - lib/capistrano-runit/templates/run-unicorn.erb
56
59
  has_rdoc: true
57
- homepage: http://github.com/antage/capistrano-runit
60
+ homepage: https://github.com/antage/capistrano-runit
58
61
  licenses: []
59
62
 
60
63
  post_install_message: