officer 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +16 -3
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/officer +36 -4
- data/lib/officer/log.rb +1 -0
- data/lib/officer/server.rb +6 -3
- data/lib/officer.rb +1 -0
- data/officer.gemspec +5 -2
- metadata +12 -2
data/README.markdown
CHANGED
@@ -9,11 +9,24 @@ It is implemented using Ruby and Eventmachine. Inspiration comes from [elock](ht
|
|
9
9
|
|
10
10
|
## Usage
|
11
11
|
|
12
|
+
Officer uses the 'daemons' gem to simplify creating long lived background processes.
|
13
|
+
Here are some simple examples in case you aren't familiar with it.
|
14
|
+
|
15
|
+
'daemons' help information:
|
12
16
|
sudo officer --help
|
13
|
-
sudo officer start
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
Officer's help information:
|
19
|
+
sudo officer run -- --help
|
20
|
+
|
21
|
+
Run Officer in the foreground with verbose mode enabled (useful for debugging):
|
22
|
+
sudo officer run -- -v
|
23
|
+
|
24
|
+
Run Officer in the background (production mode) and listen on a specific IP and port:
|
25
|
+
sudo officer start -- -h 127.0.0.1 -p 9999
|
26
|
+
|
27
|
+
- The server listens on 0.0.0.0:11500 by default.
|
28
|
+
- All debugging and error output goes to stdout for now. The daemons gem is configured to log stdout.
|
29
|
+
- The daemons gem will create a PID file in /var/run and log files in /var/log when using the 'start' option for background mode.
|
17
30
|
|
18
31
|
## Ruby Client
|
19
32
|
|
data/Rakefile
CHANGED
@@ -14,6 +14,7 @@ begin
|
|
14
14
|
gem.add_development_dependency "json", ">= 0"
|
15
15
|
gem.add_development_dependency "activesupport", ">= 0"
|
16
16
|
gem.add_development_dependency "daemons", ">= 0"
|
17
|
+
gem.add_development_dependency "choice", ">= 0"
|
17
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
19
|
end
|
19
20
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/bin/officer
CHANGED
@@ -3,13 +3,45 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'officer'
|
5
5
|
|
6
|
-
|
6
|
+
daemon_options = {
|
7
7
|
:dir_mode => :system,
|
8
8
|
:multiple => false,
|
9
|
-
:monitor => true
|
9
|
+
:monitor => true,
|
10
|
+
:log_output => true
|
10
11
|
}
|
11
12
|
|
13
|
+
def parse_command_line
|
14
|
+
if ARGV.include? '--'
|
15
|
+
ARGV.slice! 0..ARGV.index('--')
|
16
|
+
end
|
12
17
|
|
13
|
-
|
14
|
-
|
18
|
+
Choice.options do
|
19
|
+
option :host do
|
20
|
+
short '-h'
|
21
|
+
long '--host=HOST'
|
22
|
+
desc 'The hostname or IP to bind to (default: 0.0.0.0)'
|
23
|
+
end
|
24
|
+
|
25
|
+
option :port do
|
26
|
+
short '-p'
|
27
|
+
long '--port=PORT'
|
28
|
+
desc 'The port to listen on (default: 11500)'
|
29
|
+
cast Integer
|
30
|
+
end
|
31
|
+
|
32
|
+
option :verbose do
|
33
|
+
short '-v'
|
34
|
+
long '--verbose'
|
35
|
+
desc 'Print lock information to stdout every five seconds (default: off)'
|
36
|
+
end
|
37
|
+
|
38
|
+
option :help do
|
39
|
+
long '--help'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Daemons.run_proc('officer', daemon_options) do
|
45
|
+
parse_command_line
|
46
|
+
Officer::Server.new(Choice.choices).run
|
15
47
|
end
|
data/lib/officer/log.rb
CHANGED
data/lib/officer/server.rb
CHANGED
@@ -2,10 +2,11 @@ module Officer
|
|
2
2
|
|
3
3
|
class Server
|
4
4
|
def initialize options={}
|
5
|
-
options.reverse_merge! :port => 11500, :host => '0.0.0.0'
|
5
|
+
options.reverse_merge! :port => 11500, :host => '0.0.0.0', :verbose => false
|
6
6
|
|
7
7
|
@port = options[:port]
|
8
8
|
@host = options[:host]
|
9
|
+
@verbose = options[:verbose]
|
9
10
|
end
|
10
11
|
|
11
12
|
def run
|
@@ -14,8 +15,10 @@ module Officer
|
|
14
15
|
end
|
15
16
|
|
16
17
|
EM::run do
|
17
|
-
|
18
|
-
|
18
|
+
if @verbose
|
19
|
+
EM::PeriodicTimer.new(5) do
|
20
|
+
Officer::LockStore.instance.log_state
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
EM::start_server @host, @port, Connection::Connection
|
data/lib/officer.rb
CHANGED
data/officer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{officer}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chad Remesch"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-11}
|
13
13
|
s.default_executable = %q{officer}
|
14
14
|
s.description = %q{Distributed lock server and client written in Ruby and EventMachine}
|
15
15
|
s.email = %q{chad@remesch.com}
|
@@ -56,17 +56,20 @@ Gem::Specification.new do |s|
|
|
56
56
|
s.add_development_dependency(%q<json>, [">= 0"])
|
57
57
|
s.add_development_dependency(%q<activesupport>, [">= 0"])
|
58
58
|
s.add_development_dependency(%q<daemons>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<choice>, [">= 0"])
|
59
60
|
else
|
60
61
|
s.add_dependency(%q<eventmachine>, [">= 0"])
|
61
62
|
s.add_dependency(%q<json>, [">= 0"])
|
62
63
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
63
64
|
s.add_dependency(%q<daemons>, [">= 0"])
|
65
|
+
s.add_dependency(%q<choice>, [">= 0"])
|
64
66
|
end
|
65
67
|
else
|
66
68
|
s.add_dependency(%q<eventmachine>, [">= 0"])
|
67
69
|
s.add_dependency(%q<json>, [">= 0"])
|
68
70
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
69
71
|
s.add_dependency(%q<daemons>, [">= 0"])
|
72
|
+
s.add_dependency(%q<choice>, [">= 0"])
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: officer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Remesch
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-11 00:00:00 -05:00
|
13
13
|
default_executable: officer
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,16 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: "0"
|
54
54
|
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: choice
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
55
65
|
description: Distributed lock server and client written in Ruby and EventMachine
|
56
66
|
email: chad@remesch.com
|
57
67
|
executables:
|