[Groonga-commit] groonga/fluent-plugin-droonga [master] Create database if it doesn't exist

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Apr 3 18:55:37 JST 2013


Kouhei Sutou	2013-04-03 18:55:37 +0900 (Wed, 03 Apr 2013)

  New Revision: 464dd09633430e06a948e5b9fcc3d8ee884d3b9b
  https://github.com/groonga/fluent-plugin-droonga/commit/464dd09633430e06a948e5b9fcc3d8ee884d3b9b

  Message:
    Create database if it doesn't exist

  Modified files:
    lib/fluent/plugin/out_droonga.rb

  Modified: lib/fluent/plugin/out_droonga.rb (+11 -0)
===================================================================
--- lib/fluent/plugin/out_droonga.rb    2013-04-03 14:07:29 +0900 (44eaa5a)
+++ lib/fluent/plugin/out_droonga.rb    2013-04-03 18:55:37 +0900 (2ac4734)
@@ -15,6 +15,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+require "fileutils"
 require "droonga/worker"
 require "droonga/plugin"
 
@@ -31,6 +32,7 @@ module Fluent
 
     def configure(conf)
       super
+      ensure_database
       load_handlers
     end
 
@@ -77,6 +79,15 @@ module Fluent
     end
 
     private
+    def ensure_database
+      return if File.exist?(@database)
+      FileUtils.mkdir_p(File.dirname(@database))
+      context = Groonga::Context.new
+      Groonga::Database.create(:context => context, :path => @database) do
+      end
+      context.close
+    end
+
     def load_handlers
       @handlers.each do |handler_name|
         plugin = Droonga::Plugin.new("handler", handler_name)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index