commit: 2f5ae0b2e329ee78b940c7a25e7f45b3bb09d2cd
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 02:46:44 2015 +0000
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 02:46:44 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/ag.git;a=commit;h=2f5ae0b2
Prepare real wait for status.
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
---
ag | 17 +++++++++++++++++
lib/storage.rb | 7 +------
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/ag b/ag
index 96e3195..52e8848 100755
--- a/ag
+++ b/ag
@@ -51,6 +51,13 @@ op = OptionParser.new do |opts|
$options.action = :do_delete_msg
end
+
+ opts.on('--create-index', 'Create index but do not populate. Needs --list')
do
+ abort 'Can only select one action' if $options.action != nil
+
+ $options.action = :do_create_index
+ $options.need_argument = false
+ end
opts.on('--delete-index', 'Delete index. Needs --list') do
abort 'Can only select one action' if $options.action != nil
@@ -140,6 +147,11 @@ Ag::Utils.proc_count = $options.jobs
def do_full
abort "Wrong argument type: #{$options.argmode.to_s}" unless
$options.argmode == :dir
+ begin
+ Ag::Storage.delete_index(list)
+ rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
+ $stderr.puts "Index did not exist yet. Creating." if $options.debug
+ end
Ag::Storage.create_index($options.name)
messages = $maildir.list(:cur)
@@ -199,11 +211,16 @@ def do_delete_index
begin
Ag::Storage.delete_index($options.name)
rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
+ $stderr.puts "Index does not exist: #{e}"
rescue => e
$stderr.puts "Cannot delete index: #{e}"
end
end
+def do_create_index
+ Ag::Storage.create($options.name)
+end
+
def do_reindex
#
http://babinho.net/2014/07/refresh-your-elasticsearch-index-with-zero-downtime/
abort 'Come back later.'
diff --git a/lib/storage.rb b/lib/storage.rb
index 68de268..c054f9e 100644
--- a/lib/storage.rb
+++ b/lib/storage.rb
@@ -11,12 +11,6 @@ module Ag::Storage
end
def create_index(list)
- begin
- delete_index(ist)
- rescue Elasticsearch::Transport::Transport::Errors::NotFound => e
- $stderr.puts "Index did not exist yet. Creating." if $options.debug
- end
-
$es.indices.create(
index: 'ml-' + list,
body: {
@@ -93,6 +87,7 @@ module Ag::Storage
})
# Give elasticsearch some time to process the new index
+ puts $es.cluster.health
sleep 1
end