erchef-solr 11.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.rdoc +0 -0
- data/Rakefile +66 -0
- data/bin/chef-solr +27 -0
- data/bin/chef-solr-installer +26 -0
- data/lib/chef/solr.rb +1 -0
- data/lib/chef/solr/application/solr.rb +275 -0
- data/lib/chef/solr/solr_installer.rb +386 -0
- data/lib/chef/solr/version.rb +11 -0
- data/solr/solr-home.tar.gz +0 -0
- data/solr/solr-jetty.tar.gz +0 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/unit/application/solr_spec.rb +569 -0
- metadata +78 -0
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008, 2010 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
require File.dirname(__FILE__) + '/lib/chef/solr/version'
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require 'rake'
|
23
|
+
require 'rubygems/package_task'
|
24
|
+
require '../chef/tasks/rspec.rb'
|
25
|
+
|
26
|
+
spec = eval(File.read(File.dirname(__FILE__) + "/chef-solr.gemspec"))
|
27
|
+
|
28
|
+
desc "Create solr archives"
|
29
|
+
task :tar_solr do
|
30
|
+
%w{solr-home solr-jetty}.each do |tar|
|
31
|
+
Dir.chdir(File.dirname(__FILE__) + "/solr/#{tar}") { sh "tar cvzf ../#{tar}.tar.gz *" }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
task :gem => :tar_solr
|
36
|
+
|
37
|
+
Gem::PackageTask.new(spec) do |pkg|
|
38
|
+
pkg.gem_spec = spec
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Install the gem"
|
42
|
+
task :install => :package do
|
43
|
+
sh %{gem install pkg/chef-solr-#{Chef::Solr::VERSION} --no-rdoc --no-ri}
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Uninstall the gem"
|
47
|
+
task :uninstall do
|
48
|
+
sh %{gem uninstall chef-solr -x -v #{Chef::Solr::VERSION} }
|
49
|
+
end
|
50
|
+
|
51
|
+
require 'rdoc/task'
|
52
|
+
RDoc::Task.new do |rdoc|
|
53
|
+
if File.exist?('VERSION.yml')
|
54
|
+
config = YAML.load(File.read('VERSION.yml'))
|
55
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
56
|
+
else
|
57
|
+
version = Chef::Solr::VERSION
|
58
|
+
end
|
59
|
+
|
60
|
+
rdoc.rdoc_dir = 'rdoc'
|
61
|
+
rdoc.title = "chef-solr #{version}"
|
62
|
+
rdoc.rdoc_files.include('README*')
|
63
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
64
|
+
end
|
65
|
+
|
66
|
+
task :default => :spec
|
data/bin/chef-solr
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
|
21
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "chef", "lib")))
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'chef/solr/application/solr'
|
25
|
+
|
26
|
+
Chef::Solr::Application::Solr.new.run
|
27
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2009, 2011 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
|
22
|
+
$:.unshift(File.expand_path('../../../chef/lib', __FILE__))
|
23
|
+
require 'chef/solr/solr_installer'
|
24
|
+
|
25
|
+
Chef::SolrInstaller.new(ARGV).run
|
26
|
+
|
data/lib/chef/solr.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'chef/solr/version'
|
@@ -0,0 +1,275 @@
|
|
1
|
+
#
|
2
|
+
# Author:: AJ Christensen (<aj@opscode.com)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
|
19
|
+
require 'rexml/document'
|
20
|
+
require 'chef/log'
|
21
|
+
require 'chef/config'
|
22
|
+
require 'chef/application'
|
23
|
+
require 'chef/daemon'
|
24
|
+
require 'chef/solr'
|
25
|
+
|
26
|
+
class Chef
|
27
|
+
class Solr
|
28
|
+
class Application
|
29
|
+
class Solr < Chef::Application
|
30
|
+
|
31
|
+
attr_accessor :logfile
|
32
|
+
|
33
|
+
option :config_file,
|
34
|
+
:short => "-c CONFIG",
|
35
|
+
:long => "--config CONFIG",
|
36
|
+
:default => "/etc/chef/solr.rb",
|
37
|
+
:description => "The configuration file to use"
|
38
|
+
|
39
|
+
option :log_level,
|
40
|
+
:short => "-l LEVEL",
|
41
|
+
:long => "--log_level LEVEL",
|
42
|
+
:description => "Set the log level (debug, info, warn, error, fatal)",
|
43
|
+
:proc => lambda { |l| l.to_sym }
|
44
|
+
|
45
|
+
option :log_location,
|
46
|
+
:short => "-L LOGLOCATION",
|
47
|
+
:long => "--logfile LOGLOCATION",
|
48
|
+
:description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
|
49
|
+
:proc => nil
|
50
|
+
|
51
|
+
option :pid_file,
|
52
|
+
:short => "-P PID_FILE",
|
53
|
+
:long => "--pid PIDFILE",
|
54
|
+
:description => "Set the PID file location, defaults to /tmp/chef-solr.pid",
|
55
|
+
:proc => nil
|
56
|
+
|
57
|
+
option :help,
|
58
|
+
:short => "-h",
|
59
|
+
:long => "--help",
|
60
|
+
:description => "Show this message",
|
61
|
+
:on => :tail,
|
62
|
+
:boolean => true,
|
63
|
+
:show_options => true,
|
64
|
+
:exit => 0
|
65
|
+
|
66
|
+
option :user,
|
67
|
+
:short => "-u USER",
|
68
|
+
:long => "--user USER",
|
69
|
+
:description => "User to set privilege to",
|
70
|
+
:proc => nil
|
71
|
+
|
72
|
+
option :group,
|
73
|
+
:short => "-g GROUP",
|
74
|
+
:long => "--group GROUP",
|
75
|
+
:description => "Group to set privilege to",
|
76
|
+
:proc => nil
|
77
|
+
|
78
|
+
option :daemonize,
|
79
|
+
:short => "-d",
|
80
|
+
:long => "--daemonize",
|
81
|
+
:description => "Daemonize the process",
|
82
|
+
:proc => lambda { |p| true }
|
83
|
+
|
84
|
+
option :solr_jetty_path,
|
85
|
+
:short => "-W PATH",
|
86
|
+
:long => "--solr-jetty-dir PATH",
|
87
|
+
:description => "Where to place the Solr Jetty instance"
|
88
|
+
|
89
|
+
option :solr_data_path,
|
90
|
+
:short => "-D PATH",
|
91
|
+
:long => "--solr-data-dir PATH",
|
92
|
+
:description => "Where the Solr data lives"
|
93
|
+
|
94
|
+
option :solr_home_path,
|
95
|
+
:short => "-H PATH",
|
96
|
+
:long => "--solr-home-dir PATH",
|
97
|
+
:description => "Solr home directory"
|
98
|
+
|
99
|
+
option :solr_heap_size,
|
100
|
+
:short => "-x SIZE",
|
101
|
+
:long => "--solor-heap-size SIZE",
|
102
|
+
:description => "Set the size of the Java Heap"
|
103
|
+
|
104
|
+
option :solr_java_opts,
|
105
|
+
:short => "-j OPTS",
|
106
|
+
:long => "--java-opts OPTS",
|
107
|
+
:description => "Raw options passed to Java"
|
108
|
+
|
109
|
+
option :version,
|
110
|
+
:short => "-v",
|
111
|
+
:long => "--version",
|
112
|
+
:description => "Show chef-solr version",
|
113
|
+
:boolean => true,
|
114
|
+
:proc => lambda {|v| puts "chef-solr: #{::Chef::Solr::VERSION}"},
|
115
|
+
:exit => 0
|
116
|
+
|
117
|
+
def initialize
|
118
|
+
super
|
119
|
+
end
|
120
|
+
|
121
|
+
def schema_file_path
|
122
|
+
@schema_file_path ||= File.join(Chef::Config[:solr_home_path], 'conf', 'schema.xml')
|
123
|
+
end
|
124
|
+
|
125
|
+
def solr_config_file_path
|
126
|
+
@solr_config_file_path ||= File.join(Chef::Config[:solr_home_path], 'conf', 'solrconfig.xml')
|
127
|
+
end
|
128
|
+
|
129
|
+
def schema_document
|
130
|
+
@schema_document ||= begin
|
131
|
+
File.open(schema_file_path, 'r') do |xmlsux|
|
132
|
+
REXML::Document.new(xmlsux)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def config_document
|
138
|
+
@config_document ||=begin
|
139
|
+
File.open(solr_config_file_path, 'r') do |xmlsux|
|
140
|
+
REXML::Document.new(xmlsux)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def schema_attributes
|
146
|
+
@schema_attributes ||= REXML::XPath.first(schema_document, '/schema').attributes
|
147
|
+
end
|
148
|
+
|
149
|
+
def solr_main_index_elements
|
150
|
+
location = '/config/mainIndex/'
|
151
|
+
@solr_main_index_elements ||= REXML::XPath.first(config_document, location).elements
|
152
|
+
end
|
153
|
+
|
154
|
+
def solr_schema_name
|
155
|
+
schema_attributes["name"]
|
156
|
+
end
|
157
|
+
|
158
|
+
def solr_schema_version
|
159
|
+
schema_attributes["version"]
|
160
|
+
end
|
161
|
+
|
162
|
+
def solr_main_index_max_field_length
|
163
|
+
@solr_main_index_max_field_length ||=begin
|
164
|
+
field_length_el = solr_main_index_elements.select do |el|
|
165
|
+
el.name == 'maxFieldLength'
|
166
|
+
end
|
167
|
+
|
168
|
+
field_length_el.empty? ? nil : field_length_el.first.text.to_i
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def valid_schema_name?
|
173
|
+
solr_schema_name == Chef::Solr::SCHEMA_NAME
|
174
|
+
end
|
175
|
+
|
176
|
+
def valid_schema_version?
|
177
|
+
solr_schema_version == Chef::Solr::SCHEMA_VERSION
|
178
|
+
end
|
179
|
+
|
180
|
+
def check_value_of_main_index_max_field_length
|
181
|
+
if solr_main_index_max_field_length
|
182
|
+
unless solr_main_index_max_field_length > 10000
|
183
|
+
message = "The maxFieldLimit for the mainIndex is set to #{solr_main_index_max_field_length}. "
|
184
|
+
message << "It's recommended to increase this value (in #{solr_config_file_path})."
|
185
|
+
Chef::Log.warn message
|
186
|
+
end
|
187
|
+
else
|
188
|
+
Chef::Log.warn "Unable to determine the maxFieldLimit for the mainIndex (in #{solr_config_file_path})"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def solr_home_exist?
|
193
|
+
File.directory?(Chef::Config[:solr_home_path])
|
194
|
+
end
|
195
|
+
|
196
|
+
def solr_data_dir_exist?
|
197
|
+
File.directory?(Chef::Config[:solr_data_path])
|
198
|
+
end
|
199
|
+
|
200
|
+
def solr_jetty_home_exist?
|
201
|
+
File.directory?(Chef::Config[:solr_jetty_path])
|
202
|
+
end
|
203
|
+
|
204
|
+
def assert_solr_installed!
|
205
|
+
unless solr_home_exist? && solr_data_dir_exist? && solr_jetty_home_exist?
|
206
|
+
Chef::Log.fatal "Chef Solr is not installed or solr_home_path, solr_data_path, and solr_jetty_path are misconfigured."
|
207
|
+
Chef::Log.fatal "Your current configuration is:"
|
208
|
+
Chef::Log.fatal "solr_home_path: #{Chef::Config[:solr_home_path]}"
|
209
|
+
Chef::Log.fatal "solr_data_path: #{Chef::Config[:solr_data_path]}"
|
210
|
+
Chef::Log.fatal "solr_jetty_path: #{Chef::Config[:solr_jetty_path]}"
|
211
|
+
Chef::Log.fatal "You can install Chef Solr using the chef-solr-installer script."
|
212
|
+
exit 1
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def assert_valid_schema!
|
217
|
+
unless valid_schema_name? && valid_schema_version?
|
218
|
+
Chef::Log.fatal "Your Chef Solr installation needs to be upgraded."
|
219
|
+
Chef::Log.fatal "Expected schema version #{Chef::Solr::SCHEMA_VERSION} but version #{solr_schema_version} is installed."
|
220
|
+
Chef::Log.fatal "Use chef-solr-installer to upgrade your Solr install after backing up your data."
|
221
|
+
exit 1
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def setup_application
|
226
|
+
assert_solr_installed!
|
227
|
+
assert_valid_schema!
|
228
|
+
check_value_of_main_index_max_field_length
|
229
|
+
|
230
|
+
# Need to redirect stdout and stderr so Java process inherits them.
|
231
|
+
# If -L wasn't specified, Chef::Config[:log_location] will be an IO
|
232
|
+
# object, otherwise it will be a String.
|
233
|
+
#
|
234
|
+
# Open this as a privileged user and hang onto it
|
235
|
+
if Chef::Config[:log_location].kind_of?(String)
|
236
|
+
@logfile = File.new(Chef::Config[:log_location], "a")
|
237
|
+
end
|
238
|
+
|
239
|
+
Chef::Log.level = Chef::Config[:log_level]
|
240
|
+
|
241
|
+
Chef::Daemon.change_privilege
|
242
|
+
end
|
243
|
+
|
244
|
+
def run_application
|
245
|
+
if Chef::Config[:daemonize]
|
246
|
+
Chef::Daemon.daemonize("chef-solr")
|
247
|
+
end
|
248
|
+
|
249
|
+
Dir.chdir(Chef::Config[:solr_jetty_path]) do
|
250
|
+
command = "java -Xmx#{Chef::Config[:solr_heap_size]} -Xms#{Chef::Config[:solr_heap_size]}"
|
251
|
+
command << " -Dsolr.data.dir=#{Chef::Config[:solr_data_path]}"
|
252
|
+
command << " -Dsolr.solr.home=#{Chef::Config[:solr_home_path]}"
|
253
|
+
command << " #{Chef::Config[:solr_java_opts]}" if Chef::Config[:solr_java_opts]
|
254
|
+
command << " -jar #{File.join(Chef::Config[:solr_jetty_path], 'start.jar')}"
|
255
|
+
Chef::Log.info("Starting Solr with #{command}")
|
256
|
+
|
257
|
+
# Opened earlier before we dropped privileges, don't need it anymore
|
258
|
+
close_and_reopen_log_file if @logfile
|
259
|
+
|
260
|
+
Kernel.exec(command)
|
261
|
+
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def close_and_reopen_log_file
|
266
|
+
Chef::Log.close
|
267
|
+
|
268
|
+
STDOUT.reopen(@logfile)
|
269
|
+
STDERR.reopen(@logfile)
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|