capistrano-resque 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +29 -0
- data/README.md +3 -0
- data/Rakefile +2 -0
- data/capistrano-resque.gemspec +19 -0
- data/lib/capistrano-resque.rb +2 -0
- data/lib/capistrano-resque/capistrano_integration.rb +59 -0
- data/lib/capistrano-resque/version.rb +5 -0
- metadata +86 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
capistrano-resque (0.0.1)
|
5
|
+
capistrano
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
capistrano (2.11.2)
|
11
|
+
highline
|
12
|
+
net-scp (>= 1.0.0)
|
13
|
+
net-sftp (>= 2.0.0)
|
14
|
+
net-ssh (>= 2.0.14)
|
15
|
+
net-ssh-gateway (>= 1.1.0)
|
16
|
+
highline (1.6.11)
|
17
|
+
net-scp (1.0.4)
|
18
|
+
net-ssh (>= 1.99.1)
|
19
|
+
net-sftp (2.0.5)
|
20
|
+
net-ssh (>= 2.0.9)
|
21
|
+
net-ssh (2.3.0)
|
22
|
+
net-ssh-gateway (1.1.0)
|
23
|
+
net-ssh (>= 1.99.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
capistrano-resque!
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/capistrano-resque/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "capistrano-resque"
|
6
|
+
gem.version = CapistranoResque::VERSION.dup
|
7
|
+
gem.author = "Steven Shingler"
|
8
|
+
gem.email = "shingler@gmail.com"
|
9
|
+
gem.homepage = "https://github.com/sshingler/capistrano-resque"
|
10
|
+
gem.summary = %q{Resque integration for Capistrano}
|
11
|
+
gem.description = %q{Capistrano plugin that integrates Resque server tasks.}
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
|
18
|
+
gem.add_runtime_dependency "capistrano"
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "capistrano"
|
2
|
+
require "capistrano/version"
|
3
|
+
|
4
|
+
module CapistranoResque
|
5
|
+
class CapistranoIntegration
|
6
|
+
def self.load_into(capistrano_config)
|
7
|
+
capistrano_config.load do
|
8
|
+
|
9
|
+
_cset(:num_of_queues, 1)
|
10
|
+
_cset(:queue_name, "*")
|
11
|
+
_cset(:app_env, (fetch(:rails_env) rescue "production"))
|
12
|
+
_cset(:verbosity, 1)
|
13
|
+
|
14
|
+
def remote_file_exists?(full_path)
|
15
|
+
"true" == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
|
16
|
+
end
|
17
|
+
|
18
|
+
def remote_process_exists?(pid_file)
|
19
|
+
capture("ps -p $(cat #{pid_file}) ; true").strip.split("\n").size == 2
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :resque do
|
23
|
+
desc "Start Resque workers"
|
24
|
+
task :start_workers do
|
25
|
+
puts "Starting #{num_of_queues} worker(s) with QUEUE: #{queue_name}"
|
26
|
+
num_of_queues.times do |i|
|
27
|
+
pid = "./tmp/pids/resque_worker_#{i}.pid"
|
28
|
+
run "cd #{current_path} && RAILS_ENV=#{app_env} QUEUE=#{queue_name} \
|
29
|
+
PIDFILE=#{pid} BACKGROUND=yes VVERBOSE=#{verbosity} \
|
30
|
+
bundle exec rake environment resque:work > log/resque_worker_#{i}.log"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Quit running Resque workers"
|
35
|
+
task :stop_workers do
|
36
|
+
num_of_queues.times do |i|
|
37
|
+
pid = "#{current_path}/tmp/pids/resque_worker_#{i}.pid"
|
38
|
+
if remote_file_exists?(pid)
|
39
|
+
if remote_process_exists?(pid)
|
40
|
+
logger.important("Stopping...", "Resque Worker #{i}")
|
41
|
+
run "#{try_sudo} kill `cat #{pid}`"
|
42
|
+
else
|
43
|
+
run "rm #{pid}"
|
44
|
+
logger.important("Resque Worker #{i} is not running.", "Resque")
|
45
|
+
end
|
46
|
+
else
|
47
|
+
logger.important("No PIDs found. Check if Resque is running.", "Resque")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if Capistrano::Configuration.instance
|
58
|
+
CapistranoResque::CapistranoIntegration.load_into(Capistrano::Configuration.instance)
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-resque
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Steven Shingler
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-04-18 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: capistrano
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: Capistrano plugin that integrates Resque server tasks.
|
35
|
+
email: shingler@gmail.com
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files: []
|
41
|
+
|
42
|
+
files:
|
43
|
+
- Gemfile
|
44
|
+
- Gemfile.lock
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- capistrano-resque.gemspec
|
48
|
+
- lib/capistrano-resque.rb
|
49
|
+
- lib/capistrano-resque/capistrano_integration.rb
|
50
|
+
- lib/capistrano-resque/version.rb
|
51
|
+
homepage: https://github.com/sshingler/capistrano-resque
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.8.15
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Resque integration for Capistrano
|
84
|
+
test_files: []
|
85
|
+
|
86
|
+
has_rdoc:
|