beanworker 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.0.4 2011-10-24
2
+
3
+ * 1 minor enhancement:
4
+ * moar logging
5
+
1
6
  === 0.0.3 2011-10-24
2
7
 
3
8
  * 1 major enhancement:
data/README.rdoc CHANGED
@@ -5,6 +5,7 @@
5
5
  == DESCRIPTION:
6
6
 
7
7
  It is a worker-side Beanstalk-based job-queueing dispatcher
8
+
8
9
  This is a pre-release, I will complete tests and docs in couple days
9
10
 
10
11
  == REQUIREMENTS:
@@ -17,7 +18,9 @@ beanstalk-client
17
18
  $ beanworker <jobs.rb> <host:port|path/to/file.yml> [-d|--daemonize [-m|--monitor] [-P|--pid <path/to/pid/dir>] ]
18
19
 
19
20
  -d|--daemonize - process will go in background
21
+
20
22
  -m|--monitor - process will be started with monitor, that will restart it when it crushes
23
+
21
24
  -P|--pid - path to the directory, where pid-file(s) will be saved, default is current directory
22
25
 
23
26
  == DSL
@@ -58,7 +61,16 @@ jobs.rb:
58
61
 
59
62
  == API:
60
63
 
61
- TODO
64
+ RDoc will be later
65
+
66
+ Beanworker::Worker.perform number_of_threads, *jobs_names_to_listen
67
+
68
+ Beanworker::Worker.schedule method_name, period_to_run_in_secs, options={}, *args_to_method
69
+
70
+ options are:
71
+ - at: if period is in days (p % 1.day == 0), job will be performed exact at this time
72
+ - timeout: job will be killed if it performs more than this time in secs
73
+
62
74
 
63
75
  == INSTALL:
64
76
 
data/bin/beanworker CHANGED
@@ -3,6 +3,8 @@ if ARGV[0] == '-h' || ARGV[0] == '--help'
3
3
  abort 'beanworker <jobs.rb> <host:port|path/to/file.yml> [-d|--daemonize] [-m|--monitor] [-P|--pid <path/to/pid/dir>]'
4
4
  end
5
5
 
6
+ require File.expand_path('../../lib/beanworker', __FILE__)
7
+
6
8
  if ARGV[0] == '-v' || ARGV[0] == '--version'
7
9
  abort Beanworker::VERSION
8
10
  end
@@ -22,6 +24,4 @@ trap('INT') do
22
24
  exit
23
25
  end
24
26
 
25
-
26
- require File.expand_path('../../lib/beanworker', __FILE__)
27
27
  Beanworker.run opts
@@ -10,7 +10,7 @@ module Beanworker
10
10
  Thread.new do
11
11
  connection = Beanqueue.connect Beanworker.connection_config
12
12
  tubes.each { |tube| connection.watch(tube.to_s.gsub('_', '.')) }
13
- logger.info("Listening: #{tubes.inspect}") if logger
13
+ logger.info "Listening: #{tubes.inspect}"
14
14
  loop do
15
15
  get_one_job connection
16
16
  end
@@ -47,11 +47,12 @@ module Beanworker
47
47
  rescue SystemExit
48
48
  raise
49
49
  rescue => e
50
- logger.error(e.backtrace.unshift(e.message)) if logger
50
+ logger.error e.backtrace.unshift(e.message)
51
51
  job.bury rescue nil
52
52
  end
53
53
 
54
54
  def work_job(name, ttr, args, need_fork=false)
55
+ logger.info "Starting #{name} with #{args.inspect}"
55
56
  if need_fork
56
57
  Process.wait(Process.fork do
57
58
  work_with_timeout(name, ttr, args)
@@ -59,6 +60,7 @@ module Beanworker
59
60
  else
60
61
  work_with_timeout(name, ttr, args)
61
62
  end
63
+ logger.info "Finished #{name} with #{args.inspect}"
62
64
  end
63
65
 
64
66
  def work_with_timeout(name, ttr, args)
data/lib/beanworker.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  #coding: utf-8
2
2
  require 'daemons'
3
3
  require 'beanqueue'
4
+ require 'logger'
4
5
  require File.dirname(__FILE__) + '/beanworker/worker'
5
6
 
6
7
  module Beanworker
7
- VERSION = '0.0.3'
8
+ VERSION = '0.0.4'
8
9
 
9
10
  class << self
10
11
  attr_accessor :connection_config
@@ -20,7 +21,7 @@ module Beanworker
20
21
  end
21
22
  end
22
23
 
23
- def run_loop(opts)
24
+ def run_loop(opts={})
24
25
  require opts[:jobs_file]
25
26
  loop { gets } unless opts[:no_wait]
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beanworker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beanstalk-client
16
- requirement: &7708700 !ruby/object:Gem::Requirement
16
+ requirement: &22123460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *7708700
24
+ version_requirements: *22123460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: beanqueue
27
- requirement: &7705900 !ruby/object:Gem::Requirement
27
+ requirement: &22122860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *7705900
35
+ version_requirements: *22122860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hoe
38
- requirement: &7704520 !ruby/object:Gem::Requirement
38
+ requirement: &22095800 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,9 +43,10 @@ dependencies:
43
43
  version: '2.12'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *7704520
46
+ version_requirements: *22095800
47
47
  description: ! 'It is a worker-side Beanstalk-based job-queueing dispatcher
48
48
 
49
+
49
50
  This is a pre-release, I will complete tests and docs in couple days'
50
51
  email:
51
52
  - gearhead@it-primorye.ru
@@ -90,7 +91,7 @@ rubyforge_project: beanworker
90
91
  rubygems_version: 1.8.10
91
92
  signing_key:
92
93
  specification_version: 3
93
- summary: It is a worker-side Beanstalk-based job-queueing dispatcher This is a pre-release,
94
+ summary: It is a worker-side Beanstalk-based job-queueing dispatcher This is a pre-release,
94
95
  I will complete tests and docs in couple days
95
96
  test_files:
96
97
  - test/test_beanworker.rb