[Groonga-commit] droonga/chef-cookbooks at 62c1631 [master] Add droonga::engine recipe

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jan 24 17:33:59 JST 2014


Kouhei Sutou	2014-01-24 17:33:59 +0900 (Fri, 24 Jan 2014)

  New Revision: 62c16315b16451334a6ff8d315ca62d09241cef2
  https://github.com/droonga/chef-cookbooks/commit/62c16315b16451334a6ff8d315ca62d09241cef2

  Message:
    Add droonga::engine recipe
    
    It is not completed yet.

  Added files:
    droonga/templates/default/droonga-engine-catalog.json.erb
    droonga/templates/default/droonga-engine-fluentd.conf.erb
    droonga/templates/default/sv-droonga-engine-log-config.erb
    droonga/templates/default/sv-droonga-engine-run.erb
  Removed files:
    droonga/recipes/user.rb
  Modified files:
    droonga/attributes/default.rb
    droonga/metadata.rb
    droonga/recipes/engine.rb

  Modified: droonga/attributes/default.rb (+1 -0)
===================================================================
--- droonga/attributes/default.rb    2014-01-24 15:03:12 +0900 (857515a)
+++ droonga/attributes/default.rb    2014-01-24 17:33:59 +0900 (b7f56a7)
@@ -1,3 +1,4 @@
 default.droonga.engine.user_name  = "droonga-engine"
 default.droonga.engine.group_name = "droonga-engine"
 default.droonga.engine.home       = "/home/droonga-engine"
+default.droonga.engine.ruby       = "ruby"

  Modified: droonga/metadata.rb (+6 -0)
===================================================================
--- droonga/metadata.rb    2014-01-24 15:03:12 +0900 (41da771)
+++ droonga/metadata.rb    2014-01-24 17:33:59 +0900 (bd2ec84)
@@ -5,3 +5,9 @@ license          'Apache 2.0'
 description      'Installs/Configures droonga'
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
 version          '0.1.0'
+
+recipe "droonga", "Installs and configures Droonga engine and protocol adapter"
+
+depends "runit"
+depends "build-essential"
+depends "groonga"

  Modified: droonga/recipes/engine.rb (+90 -1)
===================================================================
--- droonga/recipes/engine.rb    2014-01-24 15:03:12 +0900 (751c1dd)
+++ droonga/recipes/engine.rb    2014-01-24 17:33:59 +0900 (9bfef21)
@@ -17,4 +17,93 @@
 # limitations under the License.
 #
 
-include_recipe "droonga::user"
+include_recipe "build-essential"
+include_recipe "groonga::development"
+
+droonga_engine = node.droonga.engine
+
+user_name  = droonga_engine.user_name
+group_name = droonga_engine.group_name
+home_dir   = droonga_engine.home
+ruby       = droonga_engine.ruby
+
+service_name = "droonga-engine"
+
+group group_name do
+end
+
+user user_name do
+  home     home_dir
+  group    group_name
+  password nil
+  supports :manage_home => true
+end
+
+gem_package "bundler" do
+  action :install
+end
+
+deploy "#{home_dir}/droonga-engine" do
+  repo "https://github.com/droonga/fluent-plugin-droonga"
+  user user_name
+  group group_name
+  shallow_clone
+  keep_releases 10
+  purge_before_symlink ["log", "tmp/pids"]
+  create_dirs_before_symlink ["tmp"]
+  symlink_before_migrate "config" => "config"
+  symlinks "pids" => "tmp/pids",
+           "log" => "log"
+  action :deploy
+
+  migrate true
+  migration_command "pwd; bundle install --path vendor/bundle --binstubs --shebang $(which ruby)"
+
+  before_migrate do
+    log_dir = "#{new_resource.shared_path}/log"
+    directory log_dir do
+      user user_name
+      group group_name
+      mode 0755
+    end
+
+    config_dir = "#{new_resource.shared_path}/config"
+    directory config_dir do
+      user user_name
+      group group_name
+      mode 0755
+    end
+
+    template "#{config_dir}/fluentd.conf" do
+      source "droonga-engine-fluentd.conf.erb"
+      user user_name
+      group group_name
+      mode 0644
+    end
+
+    template "#{config_dir}/catalog.conf" do
+      source "droonga-engine-catalog.json.erb"
+      user user_name
+      group group_name
+      mode 0644
+    end
+  end
+
+  notifies :restart, "runit_service[#{service_name}]"
+end
+
+package "runit" do
+end
+
+runit_service service_name do
+  log true
+  default_logger true
+end
+
+log_dir = "/var/log/#{service_name}"
+log_config = "#{log_dir}/config"
+template log_config do
+  source "sv-droonga-engine-log-config.erb"
+  mode 0644
+end
+

  Deleted: droonga/recipes/user.rb (+0 -34) 100644
===================================================================
--- droonga/recipes/user.rb    2014-01-24 15:03:12 +0900 (159b153)
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Cookbook Name:: droonga
-# Recipe:: user
-#
-# Copyright 2014, Kouhei Sutou
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-droonga_engine = node["droonga"]["engine"]
-
-user_name  = droonga_engine["user_name"]
-group_name = droonga_engine["group_name"]
-home_dir   = droonga_engine["home"]
-
-group group_name do
-end
-
-user user_name do
-  home     home_dir
-  group    group_name
-  password nil
-  supports :manage_home => true
-end

  Added: droonga/templates/default/droonga-engine-catalog.json.erb (+43 -0) 100644
===================================================================
--- /dev/null
+++ droonga/templates/default/droonga-engine-catalog.json.erb    2014-01-24 17:33:59 +0900 (5fc8a9d)
@@ -0,0 +1,43 @@
+{
+  "effective_date": "2014-01-24T00:00:00Z",
+  "zones": ["localhost:23003/droonga"],
+  "farms": {
+    "localhost:23003/droonga": {
+      "device": ".",
+      "capacity": 10
+    }
+  },
+  "datasets": {
+    "Droonga": {
+      "workers": 2,
+      "plugins": ["search", "groonga", "add"],
+      "number_of_replicas": 2,
+      "number_of_partitions": 2,
+      "partition_key": "_key",
+      "date_range": "infinity",
+      "ring": {
+        "localhost:23041": {
+          "weight": 50,
+          "partitions": {
+            "2014-01-24": [
+              "localhost:23003/droonga.000",
+              "localhost:23003/droonga.001"
+            ]
+          }
+        },
+        "localhost:23042": {
+          "weight": 50,
+          "partitions": {
+            "2014-01-24": [
+              "localhost:23003/droonga.002",
+              "localhost:23003/droonga.003"
+            ]
+          }
+        }
+      }
+    }
+  },
+  "options": {
+    "plugins": ["groonga"]
+  }
+}

  Added: droonga/templates/default/droonga-engine-fluentd.conf.erb (+11 -0) 100644
===================================================================
--- /dev/null
+++ droonga/templates/default/droonga-engine-fluentd.conf.erb    2014-01-24 17:33:59 +0900 (1e26357)
@@ -0,0 +1,11 @@
+<source>
+  type forward
+  port 23003
+</source>
+<match droonga.message>
+  name localhost:23003/droonga
+  type droonga
+</match>
+<match output.message>
+  type stdout
+</match>

  Added: droonga/templates/default/sv-droonga-engine-log-config.erb (+1 -0) 100644
===================================================================
--- /dev/null
+++ droonga/templates/default/sv-droonga-engine-log-config.erb    2014-01-24 17:33:59 +0900 (b2729ac)
@@ -0,0 +1 @@
+n30

  Added: droonga/templates/default/sv-droonga-engine-run.erb (+19 -0) 100755
===================================================================
--- /dev/null
+++ droonga/templates/default/sv-droonga-engine-run.erb    2014-01-24 17:33:59 +0900 (72b07f4)
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+exec 2>&1
+
+set -e
+set -u
+
+ulimit -n 20480
+
+user="<%= node.droonga.engine.user_name %>"
+group="<%= node.droonga.engine.group_name %>"
+work_dir="$(echo ~${user})/droonga-engine/current"
+config_dir="${work_dir}/config"
+
+fluentd_conf="${config_dir}/fluentd.conf"
+export DROONGA_CATALOG="${config_dir}/catalog.json"
+
+cd "$work_dir"
+exec chpst -u "$user:$group" bin/fluentd --config "${fluentd_conf}"
-------------- next part --------------
HTML����������������������������...
Download 



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