revenant 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/LICENSE +22 -0
  2. data/README +67 -0
  3. data/example/daemon +57 -0
  4. metadata +7 -4
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2010 Wilson Bilkovich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,67 @@
1
+ = revenant
2
+
3
+ * http://github.com/wilson/revenant
4
+
5
+ == DESCRIPTION:
6
+
7
+ Death is only a beginning. Failure will not be forgotten.
8
+
9
+ == FEATURES:
10
+
11
+ * Dead simple distributed locking
12
+ * Start as many masters as you want, only one will execute at a time
13
+ * Currently supports MySQL GET_LOCK()
14
+
15
+ == SYNOPSIS:
16
+
17
+ Have some work that needs to be done without worrying about mutual exclusion?
18
+ Lots of scheduled jobs to coordinate that must not interfere?
19
+ Want that work to keep happening when servers die?
20
+
21
+ #!/usr/bin/env ruby
22
+ require 'revenant'
23
+ task = revenant(:example)
24
+ task.on_load { require 'config/environment.rb' }
25
+ task.on_exit { something_to_do_last }
26
+ # start working and exit the parent process:
27
+ task.run { some_work_protected_by_mysql_lock }
28
+
29
+ Want to run without a distributed lock?
30
+ task.lock_function { true }
31
+ Want your code to sleep forever?
32
+ task.lock_function { false }
33
+
34
+ See the 'example' directory for more.
35
+
36
+ == REQUIREMENTS:
37
+
38
+ * mysql (not a dependency, but you will probably want it)
39
+
40
+ == INSTALL:
41
+
42
+ * gem install revenant
43
+
44
+ == LICENSE:
45
+
46
+ (The MIT License)
47
+
48
+ Copyright (c) 2010 Wilson Bilkovich
49
+
50
+ Permission is hereby granted, free of charge, to any person obtaining
51
+ a copy of this software and associated documentation files (the
52
+ 'Software'), to deal in the Software without restriction, including
53
+ without limitation the rights to use, copy, modify, merge, publish,
54
+ distribute, sublicense, and/or sell copies of the Software, and to
55
+ permit persons to whom the Software is furnished to do so, subject to
56
+ the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be
59
+ included in all copies or substantial portions of the Software.
60
+
61
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
62
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
63
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
64
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
65
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
66
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
67
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load a copy of revenant relative to this dir.
4
+ # In real code, you could use Bundler or RubyGems or similar.
5
+ require 'rubygems'
6
+ $: << File.expand_path("../../lib", __FILE__)
7
+ require 'revenant'
8
+
9
+ # Make a new task identified as 'example'.
10
+ # Yields that task to the block in case you want to reuse configuration steps.
11
+ # task.daemon = true is set by default. Set it to false if you want to
12
+ # run in the foreground without forking.
13
+ task = revenant(:example) do |t|
14
+ # Set a couple of options that are only used in daemon mode.
15
+ t.log_file = "/tmp/example.log"
16
+
17
+ # One instance of this per box:
18
+ t.pid_file = "/tmp/example.pid"
19
+ # or you could generate a different pid file for every invocation:
20
+ # t.pid_file = "/tmp/example-#{$$}.pid"
21
+ # all such processes that share a name would share a lock.
22
+
23
+ # assume we never need to check for a lock once it has been acquired
24
+ # t.relock_every = nil
25
+ end
26
+
27
+ # Runs after a fork
28
+ task.on_load do
29
+ # If we were using ActiveRecord here, the connection object
30
+ # would automatically be determined. Let's connect by hand instead.
31
+ require 'mysql'
32
+ conn = Mysql.connect(nil, "root", nil, nil, nil, "/tmp/mysql.sock")
33
+ Revenant::MySQL.connection = conn
34
+
35
+ puts "*** #{task.script} forked into pid #{$$}"
36
+ end
37
+
38
+ task.on_exit do
39
+ puts "[#{$$}] running your cleanup code"
40
+ end
41
+
42
+ # While we have the lock, do some work.
43
+ count = 0
44
+ task.run do
45
+ count += 1
46
+ puts "[#{$$}] work loops: #{count}"
47
+ end
48
+
49
+ # In daemon mode, control will not reach this point.
50
+ # With: task.daemon = false
51
+ # we would continue executing code here after the task was told to
52
+ # stop.
53
+ #
54
+ # Generally you should use 'on_exit' instead of just expecting
55
+ # code after the 'run' block to execute.
56
+
57
+ puts "[#{$$}] documentation is out of date"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2010-06-06 00:00:00.000000000 Z
12
+ date: 2014-04-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A framework for building reliable distributed workers.
15
15
  email: wilson@supremetyrant.com
@@ -17,12 +17,15 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - LICENSE
21
+ - README
20
22
  - lib/locks/mysql.rb
21
23
  - lib/plugins/daemon.rb
22
24
  - lib/revenant/manager.rb
23
25
  - lib/revenant/pid.rb
24
26
  - lib/revenant/task.rb
25
27
  - lib/revenant.rb
28
+ - example/daemon
26
29
  homepage: http://github.com/wilson/revenant
27
30
  licenses: []
28
31
  post_install_message:
@@ -43,8 +46,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
46
  version: 1.3.7
44
47
  requirements: []
45
48
  rubyforge_project:
46
- rubygems_version: 1.8.24
49
+ rubygems_version: 1.8.23.2
47
50
  signing_key:
48
- specification_version: 2
51
+ specification_version: 3
49
52
  summary: Distributed daemons that just will not die.
50
53
  test_files: []