-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix clean etc #104
base: master
Are you sure you want to change the base?
Fix clean etc #104
Changes from all commits
1529883
71534b3
92b524d
eef5040
d684ae9
0ac9704
8d83799
417c744
d5106cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ def start | |
exec('start', p: port, c: config.cloud) | ||
|
||
# Wait for solr to start | ||
unless status | ||
unless started? | ||
sleep config.poll_interval | ||
end | ||
|
||
|
@@ -101,37 +101,41 @@ def restart | |
end | ||
|
||
## | ||
# Check the status of a managed Solr service | ||
def status | ||
return true unless config.managed? | ||
# Is Solr running? | ||
def started? | ||
status_info.include? "running on port #{port}" | ||
end | ||
|
||
out = exec('status').read | ||
out =~ /running on port #{port}/ | ||
rescue | ||
false | ||
## | ||
# Check the status of a Solr service | ||
alias status started? | ||
|
||
## | ||
# Get the status information for a Solr service | ||
def status_info | ||
exec('status').read | ||
rescue => err | ||
[ | ||
'No status information available', | ||
"message: #{err.message}", | ||
"stack trace: #{err.backtrace}" | ||
].join("\n") | ||
end | ||
|
||
def pid | ||
return unless config.managed? | ||
|
||
@pid ||= begin | ||
out = exec('status').read | ||
out.match(/process (?<pid>\d+) running on port #{port}/) do |m| | ||
status_info.match(/process (?<pid>\d+) running on port #{port}/) do |m| | ||
m[:pid].to_i | ||
end | ||
end | ||
rescue | ||
nil | ||
end | ||
|
||
## | ||
# Is Solr running? | ||
def started? | ||
!!status | ||
end | ||
|
||
def wait | ||
while (Process.getpgid(pid) rescue status) | ||
while (Process.getpgid(pid) rescue started?) | ||
sleep config.poll_interval | ||
end | ||
end | ||
|
@@ -222,14 +226,16 @@ def with_collection(options = {}) | |
end | ||
|
||
## | ||
# Clean up any files solr_wrapper may have downloaded | ||
def clean! | ||
# Clean up any files solr_wrapper manages | ||
def clean!(clean_downloads: false) | ||
stop | ||
remove_instance_dir! | ||
FileUtils.remove_entry(config.download_dir, true) if File.exist?(config.download_dir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of removing this line whole-sale, let's put it behind a named parameter flag (say, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A |
||
FileUtils.remove_entry(config.tmp_save_dir, true) if File.exist? config.tmp_save_dir | ||
md5.clean! | ||
FileUtils.remove_entry(config.version_file) if File.exist? config.version_file | ||
FileUtils.remove_entry(config.version_file) if File.exist?(config.version_file) | ||
if clean_downloads | ||
md5.clean! | ||
FileUtils.remove_file(config.solr_zip_path, true) | ||
end | ||
end | ||
|
||
## | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear on why this change was made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
clean!
callsstop
so that's the big diff. Given that, then it's not necessary to check if it's stopped, it will get stopped.