Skip to content

Commit

Permalink
make it run
Browse files Browse the repository at this point in the history
  • Loading branch information
nz committed Apr 26, 2016
1 parent 8e63e9f commit afa05a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 8 additions & 1 deletion lib/searchyou/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ class Generator < Jekyll::Generator
safe true
priority :lowest

def self.abort(msg)
$stderr.puts(msg)
end

def self.elasticsearch_url(site)
ENV['ELASTICSEARCH_URL'] ||
ENV['BONSAI_URL'] ||
site.config['elasticsearch']['url']
((site.config||{})['elasticsearch']||{})['url'] ||
raise(ArgumentError, "No Elasticsearch URL present, skipping indexing")
end

def generate(site)
Expand All @@ -25,6 +30,8 @@ def generate(site)
end

indexer.finish
rescue => e
$stderr.puts "Searchyll: #{e.class.name} - #{e.message}"
end
end

Expand Down
9 changes: 5 additions & 4 deletions lib/searchyou/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Indexer
attr_accessor :working
attr_accessor :elasticsearch_url
attr_accessor :timestamp
attr_accessor :indexer_thread

def initialize(elasticsearch_url)
self.elasticsearch_url = elasticsearch_url
Expand All @@ -29,9 +30,9 @@ def es_index_name

# Prepare our indexing run by creating a new index.
def prepare_index
es.indices.create(
index: es_index_name
)
# es.indices.create(
# index: es_index_name
# )
# todo: mapping?
# set refresh interval to -1
# set replication to 0?
Expand Down Expand Up @@ -62,7 +63,7 @@ def current_batch
batch
end

def done!
def finish
self.working = false
indexer_thread.join
finalize!
Expand Down

0 comments on commit afa05a7

Please sign in to comment.