react 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +22 -19
- data/Rakefile +1 -1
- data/bin/react +1 -0
- data/examples/commands.yml +8 -0
- data/lib/react.rb +22 -17
- data/react.gemspec +5 -4
- metadata +6 -5
data/README.md
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
# React
|
2
2
|
|
3
|
-
React is a simple application that allows for remote execution of commands
|
4
|
-
|
5
|
-
entries - when an entry appears, then it is executing recognized command.
|
3
|
+
React is a simple application that allows for remote execution of commands,
|
4
|
+
and it uses Redis as a queue.
|
6
5
|
|
7
6
|
## Inspiration
|
8
7
|
|
9
|
-
It's inspired by Simon
|
10
|
-
in his redis-tutorial:
|
8
|
+
It's inspired by Simon Willison's example of "Queue-activated shell scripts"
|
9
|
+
in his [redis tutorial](http://simonwillison.net/static/2010/redis-tutorial/):
|
11
10
|
|
12
11
|
while [ 1 ] do
|
13
12
|
redis-cli blpop restart-httpd 0
|
14
13
|
apache2ctl graceful
|
15
14
|
done
|
16
15
|
|
17
|
-
##
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
You can simply install React using rubygems:
|
19
|
+
|
20
|
+
sudo gem install react
|
21
|
+
|
22
|
+
## Usage
|
18
23
|
|
19
24
|
Firs you have to prepare file with available commands. It can look like this:
|
20
25
|
|
@@ -26,39 +31,37 @@ Firs you have to prepare file with available commands. It can look like this:
|
|
26
31
|
reboot: |
|
27
32
|
reboot
|
28
33
|
|
29
|
-
And now you can start consumer.
|
34
|
+
And now you can start a consumer.
|
30
35
|
|
31
36
|
react my_commands.yml
|
32
37
|
|
33
|
-
##
|
38
|
+
## Pushing commands
|
34
39
|
|
35
|
-
While your consumer is working, you can push any of specified command to
|
40
|
+
While your consumer is working, you can push any of specified command to
|
36
41
|
queue (default queue name is `queue`), eg:
|
37
42
|
|
38
43
|
redis-cli lpush queue restart_httpd
|
39
44
|
redis-cli lpush queue reboot
|
40
45
|
|
46
|
+
After that consumer will pick up enqueued command names from and execute
|
47
|
+
related commands.
|
48
|
+
|
41
49
|
## Configuration
|
42
50
|
|
43
51
|
There are few more runtime options, which can be useful for you.
|
44
52
|
|
45
|
-
* you can specify queue
|
53
|
+
* you can specify queue which will be consumed:
|
46
54
|
|
47
|
-
|
55
|
+
react my_commands.yml --queue "my:queue:name"
|
48
56
|
|
49
57
|
* you can specify the database to which consumer should connect:
|
50
58
|
|
51
|
-
|
59
|
+
react my_commands.yml --host "yourhost.com" --port 6379 --db 2 --password pass
|
52
60
|
|
53
61
|
* and finally, you can demonize the consumer:
|
54
62
|
|
55
|
-
|
56
|
-
|
57
|
-
## Links
|
58
|
-
|
59
|
-
* [My website](http://nu7hatch.com/)
|
60
|
-
* [Simon Wilson's Redis tutorial](http://simonwillison.net/static/2010/redis-tutorial/)
|
61
|
-
|
63
|
+
react my_commands.yml --daemon
|
64
|
+
|
62
65
|
## Note on Patches/Pull Requests
|
63
66
|
|
64
67
|
* Fork the project.
|
data/Rakefile
CHANGED
data/bin/react
CHANGED
@@ -28,6 +28,7 @@ opts = OptionParser.new do |opts|
|
|
28
28
|
opts.on('-h', '--host [HOST]', 'Select redis host') {|val| val and options[:redis][:host] = val }
|
29
29
|
opts.on('-p', '--port [PORT]', Integer, 'Select redis port') {|val| val and options[:redis][:port] = val }
|
30
30
|
opts.on('-D', '--db [DATABASE]', 'Select redis database number') {|val| val and options[:redis][:db] = val }
|
31
|
+
opts.on('-P', '--password [PASSWORD]', 'Select redis database password') {|val| val and options[:redis][:password] = val }
|
31
32
|
opts.on('-d', '--daemon', 'Run in background') { options[:daemon] = true }
|
32
33
|
end.parse(ARGV)
|
33
34
|
|
data/lib/react.rb
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
require 'redis'
|
2
2
|
require 'thread'
|
3
3
|
|
4
|
-
# React is a simple application that allows for remote execution of commands
|
5
|
-
#
|
6
|
-
# entries - when an entry appears, then it is executing recognized command.
|
4
|
+
# React is a simple application that allows for remote execution of commands,
|
5
|
+
# and it uses Redis as a queue.
|
7
6
|
#
|
8
7
|
# == Inspiration
|
9
8
|
#
|
10
|
-
# It's inspired by Simon
|
11
|
-
# in his redis
|
9
|
+
# It's inspired by Simon Willison's example of "Queue-activated shell scripts"
|
10
|
+
# in his redis tutorial:
|
12
11
|
#
|
13
12
|
# while [ 1 ] do
|
14
13
|
# redis-cli blpop restart-httpd 0
|
15
14
|
# apache2ctl graceful
|
16
15
|
# done
|
17
16
|
#
|
18
|
-
# ==
|
17
|
+
# == Usage
|
19
18
|
#
|
20
19
|
# Firs you have to prepare file with available commands. It can look like this:
|
21
20
|
#
|
@@ -31,26 +30,32 @@ require 'thread'
|
|
31
30
|
#
|
32
31
|
# react my_commands.yml
|
33
32
|
#
|
34
|
-
# ==
|
33
|
+
# == Pushing commands
|
35
34
|
#
|
36
|
-
# While your consumer is working, you can push any command to
|
37
|
-
# (default queue name is `queue`), eg:
|
35
|
+
# While your consumer is working, you can push any of specified command to
|
36
|
+
# queue (default queue name is `queue`), eg:
|
38
37
|
#
|
39
38
|
# redis-cli lpush queue restart_httpd
|
40
39
|
# redis-cli lpush queue reboot
|
41
40
|
#
|
41
|
+
# After that consumer will pick up enqueued command names from and execute
|
42
|
+
# related commands.
|
43
|
+
#
|
42
44
|
# == Configuration
|
43
|
-
#
|
45
|
+
#
|
44
46
|
# There are few more runtime options, which can be useful for you.
|
45
|
-
#
|
46
|
-
# # it will be consuming commands from specified queue
|
47
|
-
# react my_commands.yml --queue "my:queue:name"
|
48
47
|
#
|
49
|
-
#
|
50
|
-
#
|
48
|
+
# * you can specify queue which will be consumed:
|
49
|
+
#
|
50
|
+
# react my_commands.yml --queue "my:queue:name"
|
51
|
+
#
|
52
|
+
# * you can specify the database to which consumer should connect:
|
53
|
+
#
|
54
|
+
# react my_commands.yml --host "yourhost.com" --port 6379 --db 2 --password pass
|
55
|
+
#
|
56
|
+
# * and finally, you can demonize the consumer:
|
51
57
|
#
|
52
|
-
#
|
53
|
-
# react my_commands.yml --daemonize
|
58
|
+
# react my_commands.yml --daemon
|
54
59
|
module React
|
55
60
|
|
56
61
|
# It starts the consumer loop.
|
data/react.gemspec
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{react}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kriss 'nu7hatch' Kowalik"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-17}
|
13
13
|
s.default_executable = %q{react}
|
14
|
-
s.description = %q{A simple application that allows remote execution of commands.}
|
14
|
+
s.description = %q{A simple application that allows for remote execution of commands.}
|
15
15
|
s.email = %q{kriss.kowalik@gmail.com}
|
16
16
|
s.executables = ["react"]
|
17
17
|
s.extra_rdoc_files = [
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"README.md",
|
26
26
|
"Rakefile",
|
27
27
|
"bin/react",
|
28
|
+
"examples/commands.yml",
|
28
29
|
"lib/react.rb",
|
29
30
|
"react.gemspec",
|
30
31
|
"test/react_test.rb",
|
@@ -34,7 +35,7 @@ Gem::Specification.new do |s|
|
|
34
35
|
s.rdoc_options = ["--charset=UTF-8"]
|
35
36
|
s.require_paths = ["lib"]
|
36
37
|
s.rubygems_version = %q{1.3.6}
|
37
|
-
s.summary = %q{Redis based remote
|
38
|
+
s.summary = %q{Redis based remote command executor.}
|
38
39
|
s.test_files = [
|
39
40
|
"test/teststrap.rb",
|
40
41
|
"test/react_test.rb"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kriss 'nu7hatch' Kowalik
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-17 00:00:00 +02:00
|
18
18
|
default_executable: react
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: "0"
|
44
44
|
type: :runtime
|
45
45
|
version_requirements: *id002
|
46
|
-
description: A simple application that allows remote execution of commands.
|
46
|
+
description: A simple application that allows for remote execution of commands.
|
47
47
|
email: kriss.kowalik@gmail.com
|
48
48
|
executables:
|
49
49
|
- react
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- README.md
|
60
60
|
- Rakefile
|
61
61
|
- bin/react
|
62
|
+
- examples/commands.yml
|
62
63
|
- lib/react.rb
|
63
64
|
- react.gemspec
|
64
65
|
- test/react_test.rb
|
@@ -92,7 +93,7 @@ rubyforge_project:
|
|
92
93
|
rubygems_version: 1.3.6
|
93
94
|
signing_key:
|
94
95
|
specification_version: 3
|
95
|
-
summary: Redis based remote
|
96
|
+
summary: Redis based remote command executor.
|
96
97
|
test_files:
|
97
98
|
- test/teststrap.rb
|
98
99
|
- test/react_test.rb
|