clockwork 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -3
- data/Gemfile.lock +12 -6
- data/README.md +23 -3
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/bin/clockworkd +85 -0
- metadata +25 -7
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
contest (0.1.3)
|
5
|
+
daemons (1.1.9)
|
5
6
|
git (1.2.5)
|
6
|
-
jeweler (1.
|
7
|
+
jeweler (1.8.4)
|
7
8
|
bundler (~> 1.0)
|
8
9
|
git (>= 1.2.5)
|
9
10
|
rake
|
11
|
+
rdoc
|
12
|
+
json (1.7.7)
|
10
13
|
metaclass (0.0.1)
|
11
|
-
mocha (0.
|
14
|
+
mocha (0.13.2)
|
12
15
|
metaclass (~> 0.0.1)
|
13
|
-
rake (0.
|
14
|
-
|
16
|
+
rake (10.0.3)
|
17
|
+
rdoc (4.0.0)
|
18
|
+
json (~> 1.4)
|
19
|
+
tzinfo (0.3.35)
|
15
20
|
|
16
21
|
PLATFORMS
|
17
22
|
ruby
|
18
23
|
|
19
24
|
DEPENDENCIES
|
20
25
|
contest
|
26
|
+
daemons
|
21
27
|
jeweler
|
22
28
|
mocha
|
23
|
-
tzinfo
|
29
|
+
tzinfo (~> 0.3.35)
|
data/README.md
CHANGED
@@ -52,6 +52,13 @@ it as the module (thanks to [hoverlover](https://github.com/hoverlover/clockwork
|
|
52
52
|
every(1.day, 'midnight.job', :at => '00:00')
|
53
53
|
end
|
54
54
|
|
55
|
+
If you need to load your entire environment for your jobs, simply add:
|
56
|
+
|
57
|
+
require './config/boot'
|
58
|
+
require './config/environment'
|
59
|
+
|
60
|
+
under the `require 'clockwork'` declaration.
|
61
|
+
|
55
62
|
Quickstart for Heroku
|
56
63
|
---------------------
|
57
64
|
|
@@ -69,8 +76,9 @@ makes it impossible to parallelize. For doing the work, you should be using a
|
|
69
76
|
job queueing system, such as
|
70
77
|
[Delayed Job](http://www.therailsway.com/2009/7/22/do-it-later-with-delayed-job),
|
71
78
|
[Beanstalk/Stalker](http://adam.heroku.com/past/2010/4/24/beanstalk_a_simple_and_fast_queueing_backend/),
|
72
|
-
[RabbitMQ/Minion](http://adamblog.heroku.com/past/2009/9/28/background_jobs_with_rabbitmq_and_minion/),
|
73
|
-
[Resque](http://github.com/blog/542-introducing-resque)
|
79
|
+
[RabbitMQ/Minion](http://adamblog.heroku.com/past/2009/9/28/background_jobs_with_rabbitmq_and_minion/),
|
80
|
+
[Resque](http://github.com/blog/542-introducing-resque), or
|
81
|
+
[Sidekiq](https://github.com/mperham/sidekiq). This design allows a
|
74
82
|
simple clock process with no locks, but also offers near infinite horizontal
|
75
83
|
scalability.
|
76
84
|
|
@@ -225,6 +233,19 @@ topography:
|
|
225
233
|
You should use Monit, God, Upstart, or Inittab to keep your clock process
|
226
234
|
running the same way you keep your web and workers running.
|
227
235
|
|
236
|
+
Daemonization
|
237
|
+
-------------
|
238
|
+
|
239
|
+
Thanks to @fddayan, `clockworkd` executes clockwork script in as a daemon.
|
240
|
+
|
241
|
+
You need `daemons` gem to use `clockworkd`. It is not automatically installed, please install by yourself.
|
242
|
+
|
243
|
+
Then,
|
244
|
+
|
245
|
+
clockworkd -c YOUR_CLOCK.rb start
|
246
|
+
|
247
|
+
For more details, see help shown by `clockworkd`.
|
248
|
+
|
228
249
|
Meta
|
229
250
|
----
|
230
251
|
|
@@ -239,4 +260,3 @@ Patches contributed by Mark McGranaghan and Lukáš Konarovský
|
|
239
260
|
Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
|
240
261
|
|
241
262
|
http://github.com/tomykaira/clockwork
|
242
|
-
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/bin/clockworkd
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
STDERR.sync = STDOUT.sync = true
|
4
|
+
|
5
|
+
require File.expand_path('../../lib/clockwork', __FILE__)
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'daemons'
|
10
|
+
rescue LoadError
|
11
|
+
raise "You need to add gem 'daemons' to your Gemfile or Rubygems if you wish to use it."
|
12
|
+
end
|
13
|
+
|
14
|
+
@options = {
|
15
|
+
:quiet => false,
|
16
|
+
:pid_dir => File.expand_path("./tmp"),
|
17
|
+
:log_output => false,
|
18
|
+
:monitor => false,
|
19
|
+
:file => File.expand_path("./clock.rb")
|
20
|
+
}
|
21
|
+
|
22
|
+
bin_basename = File.basename($0)
|
23
|
+
|
24
|
+
opts = OptionParser.new do |opts|
|
25
|
+
opts.banner = "Usage: #{bin_basename} -c FILE [options] start|stop|restart|run"
|
26
|
+
opts.separator ''
|
27
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
28
|
+
puts opts
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
opts.on("--pid-dir=DIR", "Alternate directory in which to store the process ids. Default is #{@options[:pid_dir]}.") do |dir|
|
32
|
+
@options[:pid_dir] = dir
|
33
|
+
end
|
34
|
+
opts.on('-i', '--identifier=STR', 'An identifier for the process. Default is clock file name.') do |n|
|
35
|
+
@options[:identifier] = n
|
36
|
+
end
|
37
|
+
opts.on('-l', '--log', "Redirect both STDOUT and STDERR to a logfile named #{bin_basename}[.<identifier>].output in the pid-file directory.") do
|
38
|
+
@options[:log_output] = true
|
39
|
+
end
|
40
|
+
opts.on('--log-dir=DIR', 'A specific directory to put the log files into (default location is pid directory).') do | log_dir|
|
41
|
+
@options[:log_dir] = File.expand_path(log_dir)
|
42
|
+
end
|
43
|
+
opts.on('-m', '--monitor', 'Start monitor process.') do
|
44
|
+
@options[:monitor] = true
|
45
|
+
end
|
46
|
+
opts.on('-c', '--clock=FILE',"Clock .rb file. Default is #{@options[:file]}.") do |clock_file|
|
47
|
+
@options[:file] = clock_file
|
48
|
+
@options[:file] = "./#{@options[:file]}" unless @options[:file].match(/^[\/.]/)
|
49
|
+
@options[:file] = File.expand_path(@options[:file])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
@args = opts.parse!(ARGV)
|
54
|
+
|
55
|
+
def optparser_abort(opts,message)
|
56
|
+
$stderr.puts message
|
57
|
+
puts opts
|
58
|
+
exit 1
|
59
|
+
end
|
60
|
+
|
61
|
+
optparser_abort opts, "ERROR: --clock=FILE is required." unless @options[:file]
|
62
|
+
optparser_abort opts, "ERROR: clock file #{@options[:file]} does not exist." unless File.exists?(@options[:file])
|
63
|
+
optparser_abort opts, "ERROR: File extension specified in --clock must be '.rb'" unless File.extname(@options[:file]) == ".rb"
|
64
|
+
|
65
|
+
@options[:identifier] ||= "#{File.basename(@options[:file],'.*')}"
|
66
|
+
process_name = "#{bin_basename}.#{@options[:identifier]}"
|
67
|
+
|
68
|
+
@options[:log_dir] ||= @options[:pid_dir]
|
69
|
+
|
70
|
+
Dir.mkdir(@options[:pid_dir]) unless File.exists?(@options[:pid_dir])
|
71
|
+
Dir.mkdir(@options[:log_dir]) unless File.exists?(@options[:log_dir])
|
72
|
+
|
73
|
+
puts "#{process_name}: pid file: #{File.expand_path(File.join(@options[:pid_dir],process_name + '.pid'))}"
|
74
|
+
|
75
|
+
if @options[:log_output]
|
76
|
+
puts "#{process_name}: output log file: #{File.expand_path(File.join(@options[:log_dir],process_name + '.output'))}"
|
77
|
+
else
|
78
|
+
puts "#{process_name}: No output will be printed out (run with --log if needed)"
|
79
|
+
end
|
80
|
+
|
81
|
+
Daemons.run_proc(process_name, :dir => @options[:pid_dir], :dir_mode => :normal, :monitor => @options[:monitor], :log_dir => @options[:log_dir], :log_output => @options[:log_output], :ARGV => @args) do |*args|
|
82
|
+
require @options[:file]
|
83
|
+
|
84
|
+
Clockwork::run
|
85
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clockwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,17 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tzinfo
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.3.35
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.35
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jeweler
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
35
|
- - ! '>='
|
20
36
|
- !ruby/object:Gem::Version
|
21
37
|
version: '0'
|
22
|
-
type: :
|
38
|
+
type: :development
|
23
39
|
prerelease: false
|
24
40
|
version_requirements: !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
@@ -28,7 +44,7 @@ dependencies:
|
|
28
44
|
- !ruby/object:Gem::Version
|
29
45
|
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
47
|
+
name: contest
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|
@@ -44,7 +60,7 @@ dependencies:
|
|
44
60
|
- !ruby/object:Gem::Version
|
45
61
|
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
63
|
+
name: daemons
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
49
65
|
none: false
|
50
66
|
requirements:
|
@@ -80,6 +96,7 @@ description: A scheduler process to replace cron, using a more flexible Ruby syn
|
|
80
96
|
email: adam@heroku.com
|
81
97
|
executables:
|
82
98
|
- clockwork
|
99
|
+
- clockworkd
|
83
100
|
extensions: []
|
84
101
|
extra_rdoc_files:
|
85
102
|
- README.md
|
@@ -90,6 +107,7 @@ files:
|
|
90
107
|
- Rakefile
|
91
108
|
- VERSION
|
92
109
|
- bin/clockwork
|
110
|
+
- bin/clockworkd
|
93
111
|
- lib/clockwork.rb
|
94
112
|
- test/clockwork_test.rb
|
95
113
|
homepage: http://github.com/tomykaira/clockwork
|
@@ -106,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
124
|
version: '0'
|
107
125
|
segments:
|
108
126
|
- 0
|
109
|
-
hash: -
|
127
|
+
hash: -352792223
|
110
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
129
|
none: false
|
112
130
|
requirements:
|
@@ -115,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
133
|
version: '0'
|
116
134
|
requirements: []
|
117
135
|
rubyforge_project: clockwork
|
118
|
-
rubygems_version: 1.8.
|
136
|
+
rubygems_version: 1.8.23
|
119
137
|
signing_key:
|
120
138
|
specification_version: 3
|
121
139
|
summary: A scheduler process to replace cron.
|