-
Notifications
You must be signed in to change notification settings - Fork 0
/
notions
50 lines (40 loc) · 1.44 KB
/
notions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# minimal
task = revenant(:fetcher) do |t|
t.on_load { require('config/environment.rb') }
end
task.run { Account.whatever }
# more options
task = revenant(:fetcher) do |t|
t.relock_every = 5 # every 5 loops, make sure we still have the lock
t.sleep_for = 10 # 10 seconds per lock/loop
t.lock_type = :mysql # default already
t.on_load do # after a fork
require "config/environment.rb"
end
t.on_exit do
$stderr.puts "whee!"
end
end
task.run do
Account.produce_batch_of_work
end
__END__
repeatedly call a block, but only while you have a lock
locks are a name
required options:
name
options:
type: defaults to :mysql, currently the only supported value
sleep time between loops in seconds
re-acquire lock every x loops; default is 1; nil or 0 means never check again
lock_function: block to run when acquiring a lock; returning true means this process has the lock; false otherwise.
(defaults to using the mysql connection to execute get_lock)
give a block to return the connection object: defaults to ActiveRecord::Base.connection.raw_connection
pid: defaults to /tmp/<name>.pid
on_load: a block that will execute before we start checking for a lock
on_exit: a block that will execute when the process shuts down
raise Interrupt or send TERM to shut down the process
send USR2 to restart the process with new code
'revenant' gem binary to generate executable scripts
--bundle option to generate bundler activation code?
# vim: syntax=ruby