pyramid_scheme 0.3.0 → 0.3.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/VERSION +1 -1
- data/lib/pyramid_scheme/configuration.rb +7 -4
- data/lib/pyramid_scheme/index_provider/s3.rb +9 -11
- data/lib/pyramid_scheme/index_server.rb +9 -1
- data/lib/pyramid_scheme/process_manager.rb +10 -2
- data/spec/configuration.example.yml +1 -0
- data/spec/pyramid_scheme/configuration_spec.rb +5 -0
- data/spec/pyramid_scheme/index_server_spec.rb +31 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
@@ -19,10 +19,12 @@ module PyramidScheme
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.set(&block)
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
self.defaults.each do |key, value|
|
23
|
+
if configatron.pyramid_scheme.send("#{key}").nil? || configatron.pyramid_scheme.send("#{key}") == ""
|
24
|
+
configatron.pyramid_scheme.send("#{key}=", value)
|
25
|
+
end
|
25
26
|
end
|
27
|
+
yield(configatron.pyramid_scheme)
|
26
28
|
end
|
27
29
|
|
28
30
|
def self.set_from_yml(path)
|
@@ -42,7 +44,8 @@ module PyramidScheme
|
|
42
44
|
{
|
43
45
|
:lock_file_name => 'pyramid_scheme_index_in_progress.txt',
|
44
46
|
:index_provider_class => PyramidScheme::IndexProvider::FileSystem,
|
45
|
-
:indexer_class => PyramidScheme::Indexer::ThinkingSphinx
|
47
|
+
:indexer_class => PyramidScheme::Indexer::ThinkingSphinx,
|
48
|
+
:permit_server_daemon => true
|
46
49
|
}
|
47
50
|
end
|
48
51
|
|
@@ -32,17 +32,15 @@ module PyramidScheme
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def provide_client_with_index
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
file.write chunk
|
45
|
-
end
|
35
|
+
AWS::S3::Bucket.objects(@configuration[:bucket],
|
36
|
+
:prefix => "#{@configuration[:prefix]}/").each do |obj|
|
37
|
+
|
38
|
+
unless obj.key =~ /\.new\./
|
39
|
+
new_filename = File.basename(obj.key.gsub("#{@configuration[:prefix]}/", '').gsub(/\./, ".new."))
|
40
|
+
destined_path = File.join(@configuration[:client_destination_path], new_filename)
|
41
|
+
File.open(destined_path, 'w') do |file|
|
42
|
+
AWS::S3::S3Object.stream(obj.key, @configuration[:bucket]) do |chunk|
|
43
|
+
file.write chunk
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
@@ -17,15 +17,23 @@ module PyramidScheme
|
|
17
17
|
|
18
18
|
# run the index
|
19
19
|
def index
|
20
|
+
kill_searchd unless @configuration[:permit_server_daemon]
|
20
21
|
create_lock_file
|
21
22
|
indexer.configure
|
22
23
|
indexer.index
|
23
24
|
destroy_lock_file
|
24
|
-
|
25
|
+
bounce_searchd
|
25
26
|
index_provider.process_index
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
30
|
+
def kill_searchd
|
31
|
+
PyramidScheme::ProcessManager.kill_searchd
|
32
|
+
end
|
33
|
+
|
34
|
+
def bounce_searchd
|
35
|
+
PyramidScheme::ProcessManager.bounce_searchd
|
36
|
+
end
|
29
37
|
def create_lock_file
|
30
38
|
@index_provider.lock.create
|
31
39
|
end
|
@@ -5,14 +5,22 @@ module PyramidScheme
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.bounce_searchd
|
8
|
+
kill_searchd_with_signal("HUP")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.kill_searchd
|
12
|
+
kill_searchd_with_signal("KILL")
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def self.kill_searchd_with_signal(signal)
|
8
17
|
searchd_pids.each do |process|
|
9
18
|
begin
|
10
|
-
Process.kill(
|
19
|
+
Process.kill(signal, process.pid)
|
11
20
|
rescue Exception => e
|
12
21
|
raise e unless e.message =~ /No such process/i
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
16
|
-
|
17
25
|
end
|
18
26
|
end
|
@@ -19,5 +19,10 @@ describe PyramidScheme::Configuration do
|
|
19
19
|
it 'should cast a string to a class if suffix of the configuraiton is class' do
|
20
20
|
PyramidScheme.configuration[:index_provider_class].should eql(PyramidScheme::IndexProvider::S3)
|
21
21
|
end
|
22
|
+
|
23
|
+
it 'should cast a string to boolean off of a yml file' do
|
24
|
+
#this is redundantly checking YML's functionality but we want to be sure
|
25
|
+
PyramidScheme.configuration[:permit_server_daemon].should be_false
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
@@ -50,4 +50,35 @@ describe PyramidScheme::IndexServer do
|
|
50
50
|
@server.index_provider.expects(:process_index)
|
51
51
|
@server.index
|
52
52
|
end
|
53
|
+
|
54
|
+
it 'should kill searchd if the daemon is disallowed' do
|
55
|
+
PyramidScheme.configure do |config|
|
56
|
+
config.permit_server_daemon = false
|
57
|
+
end
|
58
|
+
|
59
|
+
stub_server
|
60
|
+
|
61
|
+
PyramidScheme::ProcessManager.expects(:kill_searchd).once
|
62
|
+
|
63
|
+
@server.index
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should not kill searchd if the daemon is allowed' do
|
67
|
+
PyramidScheme.configure do |config|
|
68
|
+
config.permit_server_daemon = true
|
69
|
+
end
|
70
|
+
|
71
|
+
stub_server
|
72
|
+
|
73
|
+
PyramidScheme::ProcessManager.expects(:kill_searchd).never
|
74
|
+
|
75
|
+
@server.index
|
76
|
+
end
|
77
|
+
|
78
|
+
def stub_server
|
79
|
+
@server = PyramidScheme::IndexServer.new
|
80
|
+
@server.indexer.stubs(:configure)
|
81
|
+
@server.indexer.stubs(:index)
|
82
|
+
end
|
83
|
+
|
53
84
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Dan Pickett
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-12 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|