creeper 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/creeper.rb +5 -2
- data/lib/creeper/logger.rb +1 -1
- data/lib/creeper/version.rb +1 -1
- data/lib/creeper/worker.rb +6 -7
- metadata +1 -1
data/lib/creeper.rb
CHANGED
@@ -27,7 +27,8 @@ module Creeper
|
|
27
27
|
## default configuration ##
|
28
28
|
|
29
29
|
@beanstalk_url = ENV['BEANSTALK_URL'] || 'beanstalk://127.0.0.1/'
|
30
|
-
@
|
30
|
+
@error_logger = ::Logger.new($stderr)
|
31
|
+
@logger = ::Logger.new($stdout)
|
31
32
|
@patience_soft = 60
|
32
33
|
@patience_hard = 30
|
33
34
|
@pool_size = 2
|
@@ -100,7 +101,9 @@ module Creeper
|
|
100
101
|
def work(jobs = nil, size = 2)
|
101
102
|
require 'creeper/worker'
|
102
103
|
|
103
|
-
Creeper
|
104
|
+
Creeper.pool_size = size
|
105
|
+
|
106
|
+
Creeper::Worker.work(jobs, Creeper.pool_size)
|
104
107
|
end
|
105
108
|
|
106
109
|
##
|
data/lib/creeper/logger.rb
CHANGED
data/lib/creeper/version.rb
CHANGED
data/lib/creeper/worker.rb
CHANGED
@@ -4,7 +4,7 @@ require 'celluloid'
|
|
4
4
|
require 'creeper/celluloid_ext'
|
5
5
|
# require 'em-jack'
|
6
6
|
|
7
|
-
Creeper.
|
7
|
+
Creeper.error_logger = Celluloid.logger
|
8
8
|
|
9
9
|
module Creeper
|
10
10
|
|
@@ -16,7 +16,7 @@ module Creeper
|
|
16
16
|
|
17
17
|
options = {
|
18
18
|
size: size,
|
19
|
-
args: [jobs
|
19
|
+
args: [jobs]
|
20
20
|
}
|
21
21
|
|
22
22
|
Creeper.worker_pool = Creeper::Worker.pool(options)
|
@@ -91,11 +91,10 @@ module Creeper
|
|
91
91
|
include Celluloid
|
92
92
|
|
93
93
|
attr_accessor :number
|
94
|
-
attr_reader
|
94
|
+
attr_reader :jobs
|
95
95
|
|
96
|
-
def initialize(jobs = nil
|
97
|
-
@jobs
|
98
|
-
@pool_size = pool_size
|
96
|
+
def initialize(jobs = nil)
|
97
|
+
@jobs = self.class.jobs_for(jobs)
|
99
98
|
|
100
99
|
Creeper.register_worker(self)
|
101
100
|
Logger.info "#{prefix} Working #{self.jobs.size} jobs: [ #{self.jobs.join(' ')} ]"
|
@@ -110,7 +109,7 @@ module Creeper
|
|
110
109
|
end
|
111
110
|
|
112
111
|
def number_format
|
113
|
-
"%#{pool_size.to_s.length}d"
|
112
|
+
"%#{Creeper.pool_size.to_s.length}d"
|
114
113
|
end
|
115
114
|
|
116
115
|
def time_in_milliseconds
|