mmmurf-starling 0.9.7.10 → 0.9.8
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/CHANGELOG +15 -0
- data/Rakefile +3 -2
- data/etc/sample-config.yml +9 -0
- data/lib/starling/handler.rb +23 -23
- data/lib/starling/queue_collection.rb +1 -1
- data/lib/starling/server.rb +21 -9
- data/lib/starling/server_runner.rb +13 -8
- data/{test/test_starling_server.rb → spec/starling_server_spec.rb} +35 -35
- metadata +3 -11
data/CHANGELOG
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
== 0.9.9
|
2
|
+
* remove dependency on SyslogLogger so that starling works on windows.
|
3
|
+
|
4
|
+
== 0.9.8
|
5
|
+
* add fix to enable relative paths <david@motorator.com>
|
6
|
+
* fix tests so they don't run 10 times due to a stupid bug with how the server is forked <seth@mojodna.net>
|
7
|
+
* fix some other tests <romeda@gmail.com>
|
8
|
+
* fix some error messages <romeda@gmail.com>
|
9
|
+
* probably some other things <romeda@gmail.com>
|
10
|
+
|
11
|
+
== 0.9.7.9
|
12
|
+
* properly complain if the spool directory isn't writable <seth@mojodna.net>
|
13
|
+
* assume group and user privileges in a working order <seth@mojodna.net>
|
14
|
+
* support string user / group names in addition to uid/gids <seth@mojodna.net>
|
15
|
+
|
1
16
|
== 0.9.7.7
|
2
17
|
* added init.d scripts for redhat and ubuntu by Mike Perham <mperham@gmail.com>
|
3
18
|
* fixed dependencies for SyslogLogger, eventmachine and memcache-client by Mike Perham <mperham@gmail.com>
|
data/Rakefile
CHANGED
@@ -2,6 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'rake/rdoctask'
|
3
3
|
require 'spec/rake/spectask'
|
4
4
|
|
5
|
+
task :default => :spec
|
6
|
+
|
5
7
|
task :install do
|
6
8
|
sh %{gem build starling.gemspec}
|
7
9
|
sh %{sudo gem install starling-*.gem}
|
@@ -9,7 +11,7 @@ end
|
|
9
11
|
|
10
12
|
Spec::Rake::SpecTask.new do |t|
|
11
13
|
t.ruby_opts = ['-rtest/unit']
|
12
|
-
t.spec_files = FileList['
|
14
|
+
t.spec_files = FileList['spec/*_spec.rb']
|
13
15
|
t.fail_on_error = true
|
14
16
|
end
|
15
17
|
|
@@ -17,5 +19,4 @@ Rake::RDocTask.new do |rd|
|
|
17
19
|
rd.main = "README.rdoc"
|
18
20
|
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
19
21
|
rd.rdoc_dir = 'doc'
|
20
|
-
# rd.options = spec.rdoc_options
|
21
22
|
end
|
data/lib/starling/handler.rb
CHANGED
@@ -25,30 +25,30 @@ module StarlingServer
|
|
25
25
|
|
26
26
|
# STAT Response
|
27
27
|
STATS_COMMAND = /\Astats\r\n/m
|
28
|
-
STATS_RESPONSE = "STAT pid %d
|
29
|
-
STAT uptime %d
|
30
|
-
STAT time %d
|
31
|
-
STAT version %s
|
32
|
-
STAT rusage_user %0.6f
|
33
|
-
STAT rusage_system %0.6f
|
34
|
-
STAT curr_items %d
|
35
|
-
STAT total_items %d
|
36
|
-
STAT bytes %d
|
37
|
-
STAT curr_connections %d
|
38
|
-
STAT total_connections %d
|
39
|
-
STAT cmd_get %d
|
40
|
-
STAT cmd_set %d
|
41
|
-
STAT get_hits %d
|
42
|
-
STAT get_misses %d
|
43
|
-
STAT bytes_read %d
|
44
|
-
STAT bytes_written %d
|
45
|
-
STAT limit_maxbytes %d
|
28
|
+
STATS_RESPONSE = "STAT pid %d\r
|
29
|
+
STAT uptime %d\r
|
30
|
+
STAT time %d\r
|
31
|
+
STAT version %s\r
|
32
|
+
STAT rusage_user %0.6f\r
|
33
|
+
STAT rusage_system %0.6f\r
|
34
|
+
STAT curr_items %d\r
|
35
|
+
STAT total_items %d\r
|
36
|
+
STAT bytes %d\r
|
37
|
+
STAT curr_connections %d\r
|
38
|
+
STAT total_connections %d\r
|
39
|
+
STAT cmd_get %d\r
|
40
|
+
STAT cmd_set %d\r
|
41
|
+
STAT get_hits %d\r
|
42
|
+
STAT get_misses %d\r
|
43
|
+
STAT bytes_read %d\r
|
44
|
+
STAT bytes_written %d\r
|
45
|
+
STAT limit_maxbytes %d\r
|
46
46
|
%sEND\r\n".freeze
|
47
|
-
QUEUE_STATS_RESPONSE = "STAT queue_%s_items %d
|
48
|
-
STAT queue_%s_total_items %d
|
49
|
-
STAT queue_%s_logsize %d
|
50
|
-
STAT queue_%s_expired_items %d
|
51
|
-
STAT queue_%s_age %d\n".freeze
|
47
|
+
QUEUE_STATS_RESPONSE = "STAT queue_%s_items %d\r
|
48
|
+
STAT queue_%s_total_items %d\r
|
49
|
+
STAT queue_%s_logsize %d\r
|
50
|
+
STAT queue_%s_expired_items %d\r
|
51
|
+
STAT queue_%s_age %d\r\n".freeze
|
52
52
|
|
53
53
|
SHUTDOWN_COMMAND = /\Ashutdown\r\n/m
|
54
54
|
|
@@ -15,7 +15,7 @@ module StarlingServer
|
|
15
15
|
|
16
16
|
def initialize(path)
|
17
17
|
unless File.directory?(path) && File.writable?(path)
|
18
|
-
raise InaccessibleQueuePath.new("#{path} must exist and be writable by #{Etc.getpwuid(Process.uid).name}.")
|
18
|
+
raise InaccessibleQueuePath.new("'#{path}' must exist and be read-writable by #{Etc.getpwuid(Process.uid).name}.")
|
19
19
|
end
|
20
20
|
|
21
21
|
@shutdown_mutex = Mutex.new
|
data/lib/starling/server.rb
CHANGED
@@ -2,7 +2,6 @@ require 'socket'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'rubygems'
|
4
4
|
require 'eventmachine'
|
5
|
-
require 'analyzer_tools/syslog_logger'
|
6
5
|
|
7
6
|
here = File.dirname(__FILE__)
|
8
7
|
|
@@ -11,7 +10,7 @@ require File.join(here, 'handler')
|
|
11
10
|
|
12
11
|
module StarlingServer
|
13
12
|
|
14
|
-
VERSION = "0.9.
|
13
|
+
VERSION = "0.9.8"
|
15
14
|
|
16
15
|
class Base
|
17
16
|
attr_reader :logger
|
@@ -68,14 +67,27 @@ module StarlingServer
|
|
68
67
|
def run
|
69
68
|
@stats[:start_time] = Time.now
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
if @opts[:syslog_channel]
|
71
|
+
begin
|
72
|
+
require 'syslog_logger'
|
73
|
+
@@logger = SyslogLogger.new(@opts[:syslog_channel])
|
74
|
+
rescue LoadError
|
75
|
+
# SyslogLogger isn't available, so we're just going to use Logger
|
76
|
+
end
|
77
|
+
end
|
77
78
|
|
78
|
-
|
79
|
+
@@logger ||= case @opts[:logger]
|
80
|
+
when IO, String; Logger.new(@opts[:logger])
|
81
|
+
when Logger; @opts[:logger]
|
82
|
+
else; Logger.new(STDERR)
|
83
|
+
end
|
84
|
+
|
85
|
+
begin
|
86
|
+
@opts[:queue] = QueueCollection.new(@opts[:path])
|
87
|
+
rescue InaccessibleQueuePath => e
|
88
|
+
puts "Error: #{e.message}"
|
89
|
+
exit 1
|
90
|
+
end
|
79
91
|
@@logger.level = @opts[:log_level] || Logger::ERROR
|
80
92
|
|
81
93
|
@@logger.info "Starling STARTUP on #{@opts[:host]}:#{@opts[:port]}"
|
@@ -51,11 +51,11 @@ module StarlingServer
|
|
51
51
|
def parse_options
|
52
52
|
self.options = { :host => '127.0.0.1',
|
53
53
|
:port => 22122,
|
54
|
-
:path => File.join(
|
54
|
+
:path => File.join('', 'var', 'spool', 'starling'),
|
55
55
|
:log_level => Logger::INFO,
|
56
56
|
:daemonize => false,
|
57
57
|
:timeout => 0,
|
58
|
-
:pid_file => File.join(
|
58
|
+
:pid_file => File.join('', 'var', 'run', 'starling.pid') }
|
59
59
|
|
60
60
|
OptionParser.new do |opts|
|
61
61
|
opts.summary_width = 25
|
@@ -76,7 +76,7 @@ module StarlingServer
|
|
76
76
|
opts.on("-q", "--queue_path PATH",
|
77
77
|
:REQUIRED,
|
78
78
|
"Path to store Starling queue logs", "(default: #{options[:path]})") do |queue_path|
|
79
|
-
options[:path] = queue_path
|
79
|
+
options[:path] = File.expand_path(queue_path)
|
80
80
|
end
|
81
81
|
|
82
82
|
opts.separator ""; opts.separator "Network:"
|
@@ -96,7 +96,7 @@ module StarlingServer
|
|
96
96
|
end
|
97
97
|
|
98
98
|
opts.on("-PFILE", "--pid FILENAME", "save PID in FILENAME when using -d option.", "(default: #{options[:pid_file]})") do |pid_file|
|
99
|
-
options[:pid_file] = pid_file
|
99
|
+
options[:pid_file] = File.expand_path(pid_file)
|
100
100
|
end
|
101
101
|
|
102
102
|
opts.on("-u", "--user USER", "User to run as") do |user|
|
@@ -110,11 +110,16 @@ module StarlingServer
|
|
110
110
|
opts.separator ""; opts.separator "Logging:"
|
111
111
|
|
112
112
|
opts.on("-L", "--log [FILE]", "Path to print debugging information.") do |log_path|
|
113
|
-
options[:logger] = log_path
|
113
|
+
options[:logger] = File.expand_path(log_path)
|
114
114
|
end
|
115
115
|
|
116
|
-
|
117
|
-
|
116
|
+
begin
|
117
|
+
require 'syslog_logger'
|
118
|
+
|
119
|
+
opts.on("-l", "--syslog CHANNEL", "Write logs to the syslog instead of a log file.") do |channel|
|
120
|
+
options[:syslog_channel] = channel
|
121
|
+
end
|
122
|
+
rescue LoadError
|
118
123
|
end
|
119
124
|
|
120
125
|
opts.on("-v", "Increase logging verbosity (may be used multiple times).") do
|
@@ -216,7 +221,7 @@ module StarlingServer
|
|
216
221
|
safefork and exit
|
217
222
|
|
218
223
|
unless sess_id = Process.setsid
|
219
|
-
raise "Couldn't
|
224
|
+
raise "Couldn't detach from controlling terminal."
|
220
225
|
end
|
221
226
|
|
222
227
|
trap 'SIGHUP', 'IGNORE'
|
@@ -22,7 +22,7 @@ def safely_fork(&block)
|
|
22
22
|
while blocking
|
23
23
|
sleep 0.1
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
pid
|
27
27
|
end
|
28
28
|
|
@@ -41,7 +41,11 @@ describe "StarlingServer" do
|
|
41
41
|
:path => @tmp_path,
|
42
42
|
:logger => Logger.new(STDERR),
|
43
43
|
:log_level => Logger::FATAL)
|
44
|
-
Signal.trap("INT") {
|
44
|
+
Signal.trap("INT") {
|
45
|
+
server.stop
|
46
|
+
exit
|
47
|
+
}
|
48
|
+
|
45
49
|
Process.kill("USR1", Process.ppid)
|
46
50
|
server.run
|
47
51
|
end
|
@@ -62,7 +66,6 @@ describe "StarlingServer" do
|
|
62
66
|
@client.get('test_set_and_get_one_entry').should eql(v)
|
63
67
|
end
|
64
68
|
|
65
|
-
|
66
69
|
it "should expire entries" do
|
67
70
|
v = rand((2**32)-1)
|
68
71
|
@client.get('test_set_with_expiry').should be_nil
|
@@ -143,45 +146,42 @@ describe "StarlingServer" do
|
|
143
146
|
# handle more than 1024 connections.
|
144
147
|
|
145
148
|
unless IO::popen("uname").read.chomp == "Linux"
|
146
|
-
|
147
|
-
skip = true
|
149
|
+
pending "skipping epoll test: not on Linux"
|
148
150
|
end
|
151
|
+
|
149
152
|
fd_limit = IO::popen("bash -c 'ulimit -n'").read.chomp.to_i
|
150
153
|
unless fd_limit > 1024
|
151
|
-
|
152
|
-
skip = true
|
154
|
+
pending "skipping epoll test: 'ulimit -n' = #{fd_limit}, need > 1024"
|
153
155
|
end
|
154
156
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
unused_sockets << TCPSocket.new("127.0.0.1", 22133)
|
165
|
-
end
|
166
|
-
Process.kill("USR1", Process.ppid)
|
167
|
-
sleep 90
|
157
|
+
v = rand(2**32 - 1)
|
158
|
+
@client.set('test_epoll', v)
|
159
|
+
|
160
|
+
# we can't open 1024 connections to memcache from within this process,
|
161
|
+
# because we will hit ruby's 1024 fd limit ourselves!
|
162
|
+
pid1 = safely_fork do
|
163
|
+
unused_sockets = []
|
164
|
+
600.times do
|
165
|
+
unused_sockets << TCPSocket.new("127.0.0.1", 22133)
|
168
166
|
end
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
167
|
+
Process.kill("USR1", Process.ppid)
|
168
|
+
sleep 90
|
169
|
+
end
|
170
|
+
pid2 = safely_fork do
|
171
|
+
unused_sockets = []
|
172
|
+
600.times do
|
173
|
+
unused_sockets << TCPSocket.new("127.0.0.1", 22133)
|
176
174
|
end
|
175
|
+
Process.kill("USR1", Process.ppid)
|
176
|
+
sleep 90
|
177
|
+
end
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
end
|
179
|
+
begin
|
180
|
+
client = MemCache.new('127.0.0.1:22133')
|
181
|
+
client.get('test_epoll').should eql(v)
|
182
|
+
ensure
|
183
|
+
Process.kill("TERM", pid1)
|
184
|
+
Process.kill("TERM", pid2)
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
@@ -202,4 +202,4 @@ describe "StarlingServer" do
|
|
202
202
|
@client.reset
|
203
203
|
FileUtils.rm(Dir.glob(File.join(@tmp_path, '*')))
|
204
204
|
end
|
205
|
-
end
|
205
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mmmurf-starling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blaine Cook
|
@@ -25,15 +25,6 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: "0"
|
27
27
|
version:
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: SyslogLogger
|
30
|
-
version_requirement:
|
31
|
-
version_requirements: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: "0"
|
36
|
-
version:
|
37
28
|
- !ruby/object:Gem::Dependency
|
38
29
|
name: eventmachine
|
39
30
|
version_requirement:
|
@@ -70,6 +61,7 @@ files:
|
|
70
61
|
- lib/starling.rb
|
71
62
|
- etc/starling.redhat
|
72
63
|
- etc/starling.ubuntu
|
64
|
+
- etc/sample-config.yml
|
73
65
|
has_rdoc: true
|
74
66
|
homepage: http://github.com/mmmurf/starling/
|
75
67
|
post_install_message:
|
@@ -105,4 +97,4 @@ signing_key:
|
|
105
97
|
specification_version: 2
|
106
98
|
summary: Starling is a lightweight, transactional, distributed queue server
|
107
99
|
test_files:
|
108
|
-
-
|
100
|
+
- spec/starling_server_spec.rb
|