officer 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.markdown +5 -6
- data/lib/officer/lock_store.rb +5 -2
- data/lib/officer/runner.rb +6 -0
- data/lib/officer/server.rb +14 -1
- data/lib/officer/version.rb +1 -1
- metadata +17 -47
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -13,19 +13,18 @@ Read more in my blog post: [http://remesch.com/officer-the-ruby-lock-server-and-
|
|
13
13
|
Officer uses the 'daemons' gem to simplify creating long lived background processes.
|
14
14
|
|
15
15
|
Help information:
|
16
|
-
officer --help
|
17
16
|
|
18
|
-
Usage: officer [-
|
17
|
+
Usage: officer [-hofplsdm]
|
19
18
|
-h, --host=HOST The hostname or IP to bind to (default: 0.0.0.0)
|
20
19
|
-o, --socket-type=OPTION TCP or UNIX (default: TCP)
|
21
|
-
-f, --socket-file=FILE Full path and name to the UNIX socket file (only used
|
20
|
+
-f, --socket-file=FILE Full path and name to the UNIX domain socket file (only used with '-o UNIX', default: /tmp/officer.sock)
|
22
21
|
-p, --port=PORT The port to listen on (default: 11500)
|
23
22
|
-l, --log-level Set the log level to debug, info, or error (default: error)
|
24
23
|
-s, --stats Log stats every 5 seconds (default: off, required log level: info)
|
25
24
|
-d, --pid-dir Set directory where pid file will be saved (default: operating system's run directory)
|
25
|
+
-m, --max-idle Maximum idle time (in seconds) to wait before closing a connection that is idle and hasn't sent a keep alive (default: 60)
|
26
26
|
--help
|
27
27
|
|
28
|
-
|
29
28
|
Run Officer in the foreground with full logging and statistics:
|
30
29
|
|
31
30
|
officer run -- -l debug -s -d /tmp
|
@@ -58,7 +57,8 @@ Options:
|
|
58
57
|
- :port => TCP Port to listen on (default: 11500).
|
59
58
|
- :socket_type => TCP or UNIX (default: TCP).
|
60
59
|
- :socket_file => Full path to the server's UNIX domain socket file (default: /tmp/officer.sock). This option is only used when the socket type is UNIX.
|
61
|
-
|
60
|
+
- :namespace => Prepend a namespace to each lock name (default: empty string).
|
61
|
+
- :keep_alive_freq => Frequency (in Hz) to send a keep alive message (default: 6 Hz).
|
62
62
|
|
63
63
|
### Lock
|
64
64
|
|
@@ -67,7 +67,6 @@ Options:
|
|
67
67
|
Options:
|
68
68
|
|
69
69
|
- :timeout => The number of seconds to wait for a lock to become available (default: wait forever).
|
70
|
-
- :namespace => Prepend a namespace to each lock name (default: empty string).
|
71
70
|
- :queue_max => If the lock queue length is greater than :queue_max then don't wait for the lock (default: infinite).
|
72
71
|
|
73
72
|
|
data/lib/officer/lock_store.rb
CHANGED
@@ -161,9 +161,12 @@ module Officer
|
|
161
161
|
connection.my_locks my_locks
|
162
162
|
end
|
163
163
|
|
164
|
-
def
|
164
|
+
def close_idle_connections(max_idle)
|
165
165
|
@connections.each do |conn, names|
|
166
|
-
|
166
|
+
if conn.last_cmd_at < Time.now.utc - max_idle
|
167
|
+
Officer::Log.error "Closing due to max idle time: #{conn.to_host_s}"
|
168
|
+
conn.close_connection
|
169
|
+
end
|
167
170
|
end
|
168
171
|
end
|
169
172
|
end
|
data/lib/officer/runner.rb
CHANGED
@@ -69,6 +69,12 @@ module Officer
|
|
69
69
|
desc "Set directory where pid file will be saved (default: operating system's run directory)"
|
70
70
|
end
|
71
71
|
|
72
|
+
option :max_idle do
|
73
|
+
short '-m'
|
74
|
+
long '--max-idle'
|
75
|
+
desc "Maximum idle time (in seconds) to wait before closing a connection that is idle and hasn't sent a keep alive (default: 60)"
|
76
|
+
end
|
77
|
+
|
72
78
|
option :help do
|
73
79
|
long '--help'
|
74
80
|
end
|
data/lib/officer/server.rb
CHANGED
@@ -19,11 +19,19 @@ module Officer
|
|
19
19
|
params[:socket_file] ||= '/tmp/officer.sock'
|
20
20
|
params[:stats] ||= false
|
21
21
|
params[:log_level] ||= 'error'
|
22
|
+
params[:close_idle] = params.include?(:close_idle) ? params[:close_idle] : true
|
23
|
+
params[:max_idle] ||= 60 # Seconds.
|
22
24
|
|
23
25
|
Officer::Log.set_log_level params[:log_level]
|
24
26
|
end
|
25
27
|
|
26
28
|
def run
|
29
|
+
Officer::Log.debug 'Starting Officer with params:'
|
30
|
+
|
31
|
+
@params.each do |param, value|
|
32
|
+
Officer::Log.debug " #{param} => #{value}"
|
33
|
+
end
|
34
|
+
|
27
35
|
EM.error_handler {|e| Officer::Log.error e}
|
28
36
|
|
29
37
|
EM.kqueue = true if EM.kqueue?
|
@@ -33,7 +41,12 @@ module Officer
|
|
33
41
|
if @params[:stats]
|
34
42
|
EM::PeriodicTimer.new(5) do
|
35
43
|
Officer::LockStore.instance.log_state
|
36
|
-
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if @params[:close_idle]
|
48
|
+
EM::PeriodicTimer.new(5) do
|
49
|
+
Officer::LockStore.instance.close_idle_connections @params[:max_idle]
|
37
50
|
end
|
38
51
|
end
|
39
52
|
|
data/lib/officer/version.rb
CHANGED
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.10.
|
4
|
+
version: 0.10.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70138100800420 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *70138100800420
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: json
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70138100799880 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ! '>='
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: '0'
|
38
33
|
type: :runtime
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
35
|
+
version_requirements: *70138100799880
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: daemons
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70138100799300 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ! '>='
|
@@ -53,15 +43,10 @@ dependencies:
|
|
53
43
|
version: '0'
|
54
44
|
type: :runtime
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
46
|
+
version_requirements: *70138100799300
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
48
|
name: choice
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &70138100798800 !ruby/object:Gem::Requirement
|
65
50
|
none: false
|
66
51
|
requirements:
|
67
52
|
- - ! '>='
|
@@ -69,15 +54,10 @@ dependencies:
|
|
69
54
|
version: '0'
|
70
55
|
type: :runtime
|
71
56
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
57
|
+
version_requirements: *70138100798800
|
78
58
|
- !ruby/object:Gem::Dependency
|
79
59
|
name: rake
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &70138100798280 !ruby/object:Gem::Requirement
|
81
61
|
none: false
|
82
62
|
requirements:
|
83
63
|
- - ! '>='
|
@@ -85,15 +65,10 @@ dependencies:
|
|
85
65
|
version: '0'
|
86
66
|
type: :development
|
87
67
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
68
|
+
version_requirements: *70138100798280
|
94
69
|
- !ruby/object:Gem::Dependency
|
95
70
|
name: rspec
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirement: &70138100797740 !ruby/object:Gem::Requirement
|
97
72
|
none: false
|
98
73
|
requirements:
|
99
74
|
- - ! '>='
|
@@ -101,12 +76,7 @@ dependencies:
|
|
101
76
|
version: '0'
|
102
77
|
type: :development
|
103
78
|
prerelease: false
|
104
|
-
version_requirements:
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
79
|
+
version_requirements: *70138100797740
|
110
80
|
description: Officer is designed to help you coordinate distributed processes and
|
111
81
|
avoid race conditions.
|
112
82
|
email:
|
@@ -151,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
121
|
version: '0'
|
152
122
|
segments:
|
153
123
|
- 0
|
154
|
-
hash: -
|
124
|
+
hash: -2468263928416701502
|
155
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
126
|
none: false
|
157
127
|
requirements:
|
@@ -160,10 +130,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
130
|
version: '0'
|
161
131
|
segments:
|
162
132
|
- 0
|
163
|
-
hash: -
|
133
|
+
hash: -2468263928416701502
|
164
134
|
requirements: []
|
165
135
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.8.
|
136
|
+
rubygems_version: 1.8.17
|
167
137
|
signing_key:
|
168
138
|
specification_version: 3
|
169
139
|
summary: Ruby lock server and client built on EventMachine.
|