droonga-engine 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/bin/droonga-engine-absorb-data +2 -1
  3. data/bin/droonga-engine-catalog-generate +21 -5
  4. data/bin/droonga-engine-catalog-modify +22 -6
  5. data/bin/droonga-engine-configure +215 -0
  6. data/bin/droonga-engine-join +48 -123
  7. data/bin/droonga-engine-unjoin +14 -1
  8. data/doc/text/news.md +21 -0
  9. data/droonga-engine.gemspec +12 -10
  10. data/install/centos/droonga-engine +60 -0
  11. data/install/centos/functions.sh +35 -0
  12. data/install/debian/droonga-engine +155 -0
  13. data/install/debian/functions.sh +33 -0
  14. data/install.sh +360 -0
  15. data/lib/droonga/address.rb +3 -1
  16. data/lib/droonga/catalog/dataset.rb +2 -0
  17. data/lib/droonga/catalog/version1.rb +16 -3
  18. data/lib/droonga/catalog/version2.rb +16 -3
  19. data/lib/droonga/catalog_fetcher.rb +51 -0
  20. data/lib/droonga/catalog_generator.rb +6 -5
  21. data/lib/droonga/catalog_modifier.rb +45 -0
  22. data/lib/droonga/command/droonga_engine.rb +96 -29
  23. data/lib/droonga/command/droonga_engine_service.rb +5 -0
  24. data/lib/droonga/command/remote.rb +368 -0
  25. data/lib/droonga/command/serf_event_handler.rb +37 -304
  26. data/lib/droonga/dispatcher.rb +15 -1
  27. data/lib/droonga/engine/version.rb +1 -1
  28. data/lib/droonga/engine.rb +11 -4
  29. data/lib/droonga/engine_state.rb +2 -0
  30. data/lib/droonga/farm.rb +14 -5
  31. data/lib/droonga/fluent_message_receiver.rb +23 -6
  32. data/lib/droonga/fluent_message_sender.rb +5 -1
  33. data/lib/droonga/node_status.rb +67 -0
  34. data/lib/droonga/path.rb +28 -4
  35. data/lib/droonga/plugins/catalog.rb +40 -0
  36. data/lib/droonga/safe_file_writer.rb +1 -1
  37. data/lib/droonga/searcher.rb +3 -15
  38. data/lib/droonga/serf.rb +17 -32
  39. data/lib/droonga/serf_downloader.rb +26 -1
  40. data/lib/droonga/service_installation.rb +123 -0
  41. data/lib/droonga/session.rb +4 -0
  42. data/lib/droonga/slice.rb +22 -12
  43. data/lib/droonga/supervisor.rb +16 -2
  44. data/lib/droonga/worker_process_agent.rb +13 -1
  45. data/sample/droonga-engine.yaml +5 -0
  46. data/test/command/config/default/catalog.json +1 -1
  47. data/test/command/config/default/droonga-engine.yaml +4 -0
  48. data/test/command/config/version1/catalog.json +1 -1
  49. data/test/command/suite/catalog/fetch.expected +64 -0
  50. data/test/command/suite/catalog/fetch.test +6 -0
  51. data/test/unit/catalog/test_version1.rb +2 -2
  52. data/test/unit/catalog/test_version2.rb +3 -3
  53. data/test/unit/helper/sandbox.rb +3 -1
  54. data/test/unit/plugins/catalog/test_fetch.rb +76 -0
  55. data/test/unit/test_catalog_generator.rb +7 -3
  56. metadata +74 -27
  57. data/bin/droonga-engine-data-publisher +0 -66
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+ #
3
+ # /etc/rc.d/init.d/droonga-engine
4
+ #
5
+ # <Droonga engine is a core component in Droonga system>
6
+ # chkconfig: 2345 20 80
7
+
8
+ # TODO: we have to migrate to systemd based management in near future...
9
+ SYSTEMCTL_SKIP_REDIRECT=yes
10
+
11
+ # Source function library.
12
+ . /etc/init.d/functions
13
+
14
+ NAME=droonga-engine
15
+ USER=$NAME
16
+ GROUP=droonga
17
+ DAEMON=/usr/local/bin/$NAME
18
+ export DROONGA_BASE_DIR=/home/$NAME/droonga
19
+ cd $DROONGA_BASE_DIR
20
+ PIDFILE=/run/$NAME/$NAME.pid
21
+ DAEMON_ARGS="--daemon --pid-file=$PIDFILE"
22
+
23
+ [ -x $DAEMON ] || exit 0
24
+
25
+ start() {
26
+ echo -n "Starting $NAME: "
27
+ daemon --user $USER --pidfile $PIDFILE $DAEMON $DAEMON_ARGS
28
+ RET_CODE=$?
29
+ touch /var/lock/subsys/$NAME
30
+ return $RET_CODE
31
+ }
32
+
33
+ stop() {
34
+ echo -n "Shutting down $NAME: "
35
+ killproc -p $PIDFILE $DAEMON
36
+ RET_CODE=$?
37
+ rm -f /var/lock/subsys/$NAME
38
+ return $RET_CODE
39
+ }
40
+
41
+ case "$1" in
42
+ start)
43
+ start
44
+ ;;
45
+ stop)
46
+ stop
47
+ ;;
48
+ status)
49
+ status $NAME
50
+ ;;
51
+ restart)
52
+ stop
53
+ start
54
+ ;;
55
+ *)
56
+ echo "Usage: $NAME {start|stop|status|reload|restart[|probe]"
57
+ exit 1
58
+ ;;
59
+ esac
60
+ exit $?
@@ -0,0 +1,35 @@
1
+ # Copyright (C) 2014 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
+
16
+ register_service() {
17
+ local NAME=$1
18
+ local USER=$2
19
+ local GROUP=$3
20
+
21
+ #TODO: we should migrate to systemd in near future...
22
+
23
+ local pid_dir=/run/$NAME
24
+ mkdir -p $pid_dir
25
+ chown -R $USER:$GROUP $pid_dir
26
+
27
+ curl -o /etc/rc.d/init.d/$NAME $(download_url "install/centos/$NAME")
28
+ if [ $? -ne 0 ]; then
29
+ echo "ERROR: Failed to download service script!"
30
+ exit 1
31
+ fi
32
+
33
+ chmod +x /etc/rc.d/init.d/$NAME
34
+ /sbin/chkconfig --add $NAME
35
+ }
@@ -0,0 +1,155 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: droonga-engine
4
+ # Required-Start: $remote_fs $syslog
5
+ # Required-Stop: $remote_fs $syslog
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Droonga engine is a core component in Droonga system
9
+ ### END INIT INFO
10
+
11
+ # Do NOT "set -e"
12
+
13
+ # PATH should only include /usr/* if it runs after the mountnfs.sh script
14
+ PATH=/sbin:/usr/sbin:/bin:/usr/bin
15
+ DESC=""
16
+ NAME=droonga-engine
17
+ USER=$NAME
18
+ GROUP=droonga
19
+ DAEMON=/usr/local/bin/$NAME
20
+ export DROONGA_BASE_DIR=/home/$NAME/droonga
21
+ PIDFILE=/var/run/$NAME/$NAME.pid
22
+ DAEMON_ARGS="--daemon --pid-file=$PIDFILE"
23
+ SCRIPTNAME=/etc/init.d/$NAME
24
+
25
+ # Exit if the package is not installed
26
+ [ -x "$DAEMON" ] || exit 0
27
+
28
+ # Read configuration variable file if it is present
29
+ [ -r /etc/default/$NAME ] && . /etc/default/$NAME
30
+
31
+ # Load the VERBOSE setting and other rcS variables
32
+ . /lib/init/vars.sh
33
+
34
+ # Define LSB log_* functions.
35
+ # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
36
+ # and status_of_proc is working.
37
+ . /lib/lsb/init-functions
38
+
39
+ #
40
+ # Function that starts the daemon/service
41
+ #
42
+ do_start()
43
+ {
44
+ # Return
45
+ # 0 if daemon has been started
46
+ # 1 if daemon was already running
47
+ # 2 if daemon could not be started
48
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --user $USER --test > /dev/null \
49
+ || return 1
50
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --user $USER --chuid $USER:$GROUP --chdir $DROONGA_BASE_DIR -- \
51
+ $DAEMON_ARGS \
52
+ || return 2
53
+ # Add code here, if necessary, that waits for the process to be ready
54
+ # to handle requests from services started subsequently which depend
55
+ # on this one. As a last resort, sleep for some time.
56
+ }
57
+
58
+ #
59
+ # Function that stops the daemon/service
60
+ #
61
+ do_stop()
62
+ {
63
+ # Return
64
+ # 0 if daemon has been stopped
65
+ # 1 if daemon was already stopped
66
+ # 2 if daemon could not be stopped
67
+ # other if a failure occurred
68
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
69
+ RETVAL="$?"
70
+ [ "$RETVAL" = 2 ] && return 2
71
+ # Wait for children to finish too if this is a daemon that forks
72
+ # and if the daemon is only ever run from this initscript.
73
+ # If the above conditions are not satisfied then add some other code
74
+ # that waits for the process to drop all resources that could be
75
+ # needed by services started subsequently. A last resort is to
76
+ # sleep for some time.
77
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
78
+ [ "$?" = 2 ] && return 2
79
+ # Many daemons don't delete their pidfiles when they exit.
80
+ rm -f $PIDFILE
81
+ return "$RETVAL"
82
+ }
83
+
84
+ #
85
+ # Function that sends a SIGHUP to the daemon/service
86
+ #
87
+ do_reload() {
88
+ #
89
+ # If the daemon can reload its configuration without
90
+ # restarting (for example, when it is sent a SIGHUP),
91
+ # then implement that here.
92
+ #
93
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
94
+ return 0
95
+ }
96
+
97
+ case "$1" in
98
+ start)
99
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
100
+ do_start
101
+ case "$?" in
102
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
103
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
104
+ esac
105
+ ;;
106
+ stop)
107
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
108
+ do_stop
109
+ case "$?" in
110
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
111
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
112
+ esac
113
+ ;;
114
+ status)
115
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
116
+ ;;
117
+ #reload|force-reload)
118
+ #
119
+ # If do_reload() is not implemented then leave this commented out
120
+ # and leave 'force-reload' as an alias for 'restart'.
121
+ #
122
+ #log_daemon_msg "Reloading $DESC" "$NAME"
123
+ #do_reload
124
+ #log_end_msg $?
125
+ #;;
126
+ restart|force-reload)
127
+ #
128
+ # If the "reload" option is implemented then remove the
129
+ # 'force-reload' alias
130
+ #
131
+ log_daemon_msg "Restarting $DESC" "$NAME"
132
+ do_stop
133
+ case "$?" in
134
+ 0|1)
135
+ do_start
136
+ case "$?" in
137
+ 0) log_end_msg 0 ;;
138
+ 1) log_end_msg 1 ;; # Old process is still running
139
+ *) log_end_msg 1 ;; # Failed to start
140
+ esac
141
+ ;;
142
+ *)
143
+ # Failed to stop
144
+ log_end_msg 1
145
+ ;;
146
+ esac
147
+ ;;
148
+ *)
149
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
150
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
151
+ exit 3
152
+ ;;
153
+ esac
154
+
155
+ :
@@ -0,0 +1,33 @@
1
+ # Copyright (C) 2014 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
+
16
+ register_service() {
17
+ local NAME=$1
18
+ local USER=$2
19
+ local GROUP=$3
20
+
21
+ local pid_dir=/var/run/$NAME
22
+ mkdir -p $pid_dir
23
+ chown -R $USER:$GROUP $pid_dir
24
+
25
+ curl -o /etc/init.d/$NAME $(download_url "install/debian/$NAME")
26
+ if [ $? -ne 0 ]; then
27
+ echo "ERROR: Failed to download service script!"
28
+ exit 1
29
+ fi
30
+
31
+ chmod +x /etc/init.d/$NAME
32
+ update-rc.d $NAME defaults
33
+ }
data/install.sh ADDED
@@ -0,0 +1,360 @@
1
+ # Copyright (C) 2014 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
+
16
+ # Usage:
17
+ #
18
+ # Ubuntu:
19
+ #
20
+ # Install a release version:
21
+ # $ curl https://raw.githubusercontent.com/droonga/droonga-engine/master/install.sh | sudo bash
22
+ # Install the latest revision from the repository:
23
+ # $ curl https://raw.githubusercontent.com/droonga/droonga-engine/master/install.sh | sudo VERSION=master bash
24
+ # Install with the specified hostname (disabling auto-detection):
25
+ # $ curl https://raw.githubusercontent.com/droonga/droonga-engine/master/install.sh | sudo HOST=xxx.xxx.xxx.xxx bash
26
+ #
27
+ # CentOS 7:
28
+ #
29
+ # Install a release version:
30
+ # # curl https://raw.githubusercontent.com/droonga/droonga-engine/master/install.sh | bash
31
+ # Install the latest revision from the repository:
32
+ # # curl https://raw.githubusercontent.com/droonga/droonga-engine/master/install.sh | VERSION=master bash
33
+ # Install with the specified hostname (disabling auto-detection):
34
+ # # curl https://raw.githubusercontent.com/droonga/droonga-engine/master/install.sh | HOST=xxx.xxx.xxx.xxx bash
35
+
36
+ NAME=droonga-engine
37
+ DOWNLOAD_URL_BASE=https://raw.githubusercontent.com/droonga/$NAME
38
+ REPOSITORY_URL=https://github.com/droonga/$NAME.git
39
+ USER=$NAME
40
+ GROUP=droonga
41
+ DROONGA_BASE_DIR=/home/$USER/droonga
42
+ TEMPDIR=/tmp/install-$NAME
43
+
44
+ : ${VERSION:=release}
45
+ : ${HOST:=Auto Detect}
46
+
47
+ case $(uname) in
48
+ Darwin|*BSD|CYGWIN*) sed="sed -E" ;;
49
+ *) sed="sed -r" ;;
50
+ esac
51
+
52
+ ensure_root() {
53
+ if [ "$EUID" != "0" ]; then
54
+ echo "You must run this script as the root."
55
+ exit 1
56
+ fi
57
+ }
58
+
59
+ guess_platform() {
60
+ if [ -e /etc/debian_version ] || [ -e /etc/debian_release ]; then
61
+ echo "debian"
62
+ return 0
63
+ elif [ -e /etc/centos-release ]; then
64
+ echo "centos"
65
+ return 0
66
+ fi
67
+ return 1
68
+ }
69
+
70
+ exist_command() {
71
+ type "$1" > /dev/null 2>&1
72
+ }
73
+
74
+ exist_all_commands() {
75
+ for command in $@; do
76
+ if ! exist_command $command; then
77
+ return 1
78
+ fi
79
+ done
80
+ return 0
81
+ }
82
+
83
+ exist_yum_repository() {
84
+ if ! yum --enablerepo=$1 repolist; then
85
+ return 1
86
+ fi
87
+ yum --enablerepo=$1 repolist | grep --quiet "$1"
88
+ }
89
+
90
+ exist_user() {
91
+ id "$1" > /dev/null 2>&1
92
+ }
93
+
94
+ prepare_user() {
95
+ echo ""
96
+ echo "Preparing the user..."
97
+
98
+ groupadd $GROUP
99
+
100
+ if ! exist_user $USER; then
101
+ useradd -m $USER
102
+ fi
103
+
104
+ usermod -G $GROUP $USER
105
+ return 0
106
+ }
107
+
108
+ setup_configuration_directory() {
109
+ echo ""
110
+ echo "Setting up the configuration directory..."
111
+
112
+ [ ! -e $DROONGA_BASE_DIR ] &&
113
+ mkdir $DROONGA_BASE_DIR
114
+
115
+ if [ ! -e $DROONGA_BASE_DIR/catalog.json -o \
116
+ ! -e $DROONGA_BASE_DIR/$NAME.yaml ]; then
117
+ [ "$HOST" = "Auto Detect" ] &&
118
+ HOST=$(determine_hostname)
119
+
120
+ if [ "$HOST" = "" ]; then
121
+ HOST=$(hostname)
122
+ echo "********************** CAUTION!! **********************"
123
+ echo "Installation process coudln't detect the hostname of"
124
+ echo "this node, which is accessible from other nodes."
125
+ echo "You may have to configure droonga-engine manually"
126
+ echo "to refer a valid accessible hostname for this node,"
127
+ echo "by following command line:"
128
+ echo ""
129
+ echo " droonga-engine-configure --reset-config --reset-catalog"
130
+ echo "*******************************************************"
131
+ fi
132
+ echo "This node is configured with a hostname $HOST."
133
+ fi
134
+
135
+ droonga-engine-configure --quiet \
136
+ --host=$HOST
137
+ if [ $? -ne 0 ]; then
138
+ echo "ERROR: Failed to configure $NAME!"
139
+ exit 1
140
+ fi
141
+
142
+ chown -R $USER:$GROUP $DROONGA_BASE_DIR
143
+ }
144
+
145
+
146
+ guess_global_hostname() {
147
+ if hostname -d > /dev/null 2>&1; then
148
+ local domain=$(hostname -d)
149
+ local hostname=$(hostname -s)
150
+ if [ "$domain" != "" ]; then
151
+ echo "$hostname.$domain"
152
+ return 0
153
+ fi
154
+ fi
155
+ echo ""
156
+ return 1
157
+ }
158
+
159
+ determine_hostname() {
160
+ local global_hostname=$(guess_global_hostname)
161
+ if [ "$global_hostname" != "" ]; then
162
+ echo "$global_hostname"
163
+ return 0
164
+ fi
165
+
166
+ local address=$(hostname -i | \
167
+ $sed -e "s/127\.[0-9]+\.[0-9]+\.[0-9]+//g" \
168
+ -e "s/[0-9a-f:]+%[^ ]+//g" \
169
+ -e "s/ +/ /g" \
170
+ -e "s/^ +| +\$//g" |\
171
+ cut -d " " -f 1)
172
+ if [ "$address" != "" ]; then
173
+ echo "$address"
174
+ return 0
175
+ fi
176
+
177
+ echo ""
178
+ return 1
179
+ }
180
+
181
+ download_url() {
182
+ if [ "$VERSION" = "master" ]; then
183
+ echo "$DOWNLOAD_URL_BASE/master/$1"
184
+ else
185
+ echo "$DOWNLOAD_URL_BASE/v$(installed_version)/$1"
186
+ fi
187
+ }
188
+
189
+ installed_version() {
190
+ $NAME --version | cut -d " " -f 2
191
+ }
192
+
193
+
194
+ install_rroonga() {
195
+ # Install Rroonga globally from a public gem, because custom build
196
+ # doesn't work as we expect for Droonga...
197
+ if exist_command grndump; then
198
+ local current_version=$(grndump -v | cut -d " " -f 2)
199
+ local version_matcher=$(cat $NAME.gemspec | \
200
+ grep rroonga | \
201
+ cut -d "," -f 2 | \
202
+ cut -d '"' -f 2)
203
+ local compared_version=$(echo "$version_matcher" | \
204
+ cut -d " " -f 2)
205
+ local operator=$(echo "$version_matcher" | cut -d " " -f 1)
206
+ local compare_result=$(ruby -e "puts('$current_version' $operator '$compared_version')")
207
+ if [ "$compare_result" = "true" ]; then return 0; fi
208
+ fi
209
+ gem install rroonga --no-ri --no-rdoc
210
+ }
211
+
212
+ install_master() {
213
+ gem install bundler --no-ri --no-rdoc
214
+
215
+ cd $TEMPDIR
216
+
217
+ if [ -d $NAME ]
218
+ then
219
+ cd $NAME
220
+ install_rroonga
221
+ git reset --hard
222
+ git pull --rebase
223
+ bundle update
224
+ else
225
+ git clone $REPOSITORY_URL
226
+ cd $NAME
227
+ install_rroonga
228
+ bundle install
229
+ fi
230
+ rm -rf pkg
231
+ bundle exec rake build
232
+ gem install "pkg/*.gem" --no-ri --no-rdoc
233
+ }
234
+
235
+
236
+
237
+ # ====================== for Debian/Ubuntu ==========================
238
+ prepare_environment_in_debian() {
239
+ local use_groonga_package=no
240
+ if apt-cache policy | grep --quiet groonga; then
241
+ use_groonga_package=yes
242
+ else
243
+ if [ "$(lsb_release -i -s)" = "Ubuntu" ]; then
244
+ add-apt-repository -y ppa:groonga/ppa
245
+ use_groonga_package=yes
246
+ else
247
+ local groonga_list=/etc/apt/sources.list.d/groonga.list
248
+ echo "deb http://packages.groonga.org/debian/ wheezy main" >> $groonga_list
249
+ echo "deb-src http://packages.groonga.org/debian/ wheezy main" >> $groonga_list
250
+ apt-get update
251
+ apt-get install -y --allow-unauthenticated groonga-keyring
252
+ use_groonga_package=yes
253
+ fi
254
+ fi
255
+
256
+ apt-get update
257
+ apt-get install -y curl ruby ruby-dev build-essential
258
+
259
+ if [ "$use_groonga_package" = "yes" ]; then
260
+ apt-get install -y libgroonga-dev
261
+ fi
262
+
263
+ if [ "$VERSION" = "master" ]; then
264
+ apt-get install -y git
265
+ fi
266
+ }
267
+ # ====================== /for Debian/Ubuntu =========================
268
+
269
+
270
+
271
+ # ========================= for CentOS 7 ============================
272
+ prepare_environment_in_centos() {
273
+ local use_groonga_package=no
274
+ if ! exist_yum_repository groonga; then
275
+ rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
276
+
277
+ # disable it by default!
278
+ groonga_repo=/etc/yum.repos.d/groonga.repo
279
+ backup=/tmp/$(basename $groonga_repo).bak
280
+ mv $groonga_repo $backup
281
+ cat $backup | $sed -e "s/enabled=1/enabled=0/" \
282
+ > $groonga_repo
283
+ fi
284
+
285
+ if exist_yum_repository groonga; then
286
+ use_groonga_package=yes
287
+ yum -y --enablerepo=groonga makecache
288
+ else
289
+ yum -y makecache
290
+ fi
291
+ yum -y groupinstall development
292
+ yum -y install curl ruby-devel
293
+
294
+ if [ "$use_groonga_package" = "yes" ]; then
295
+ yum -y --enablerepo=groonga install groonga-devel
296
+ fi
297
+
298
+ if [ "$VERSION" = "master" ]; then
299
+ yum -y install git
300
+ fi
301
+ }
302
+ # ========================= /for CentOS 7 ===========================
303
+
304
+
305
+
306
+ install() {
307
+ mkdir -p $TEMPDIR
308
+
309
+ echo "Preparing the environment..."
310
+ prepare_environment_in_$PLATFORM
311
+
312
+ echo ""
313
+ if [ "$VERSION" = "master" ]; then
314
+ echo "Installing $NAME from the git repository..."
315
+ install_master
316
+ else
317
+ echo "Installing $NAME from RubyGems..."
318
+ gem install droonga-engine --no-rdoc --no-ri
319
+ fi
320
+
321
+ if ! exist_command droonga-engine; then
322
+ echo "ERROR: Failed to install $NAME!"
323
+ exit 1
324
+ fi
325
+
326
+ curl -o $TEMPDIR/functions.sh $(download_url "install/$PLATFORM/functions.sh")
327
+ if ! source $TEMPDIR/functions.sh; then
328
+ echo "ERROR: Failed to download post-installation script!"
329
+ exit 1
330
+ fi
331
+ if ! exist_command register_service; then
332
+ echo "ERROR: Downloaded post-installation script is broken!"
333
+ exit 1
334
+ fi
335
+
336
+ prepare_user
337
+
338
+ setup_configuration_directory
339
+
340
+ echo ""
341
+ echo "Registering $NAME as a service..."
342
+ # this function is defined by the downloaded "functions.sh"!
343
+ register_service $NAME $USER $GROUP
344
+
345
+ echo ""
346
+ echo "Successfully installed $NAME."
347
+ }
348
+
349
+
350
+ ensure_root
351
+
352
+ PLATFORM=$(guess_platform)
353
+ if [ "$PLATFORM" = "" ]; then
354
+ echo "Not supported platform."
355
+ exit 255
356
+ fi
357
+
358
+ install
359
+
360
+ exit 0
@@ -13,6 +13,8 @@
13
13
  # License along with this library; if not, write to the Free Software
14
14
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
15
 
16
+ require "socket"
17
+
16
18
  module Droonga
17
19
  class Address
18
20
  class << self
@@ -33,7 +35,7 @@ module Droonga
33
35
  end
34
36
  end
35
37
 
36
- DEFAULT_HOST = "127.0.0.1"
38
+ DEFAULT_HOST = Socket.gethostname
37
39
  DEFAULT_PORT = 10031
38
40
  DEFAULT_TAG = "droonga"
39
41
 
@@ -20,6 +20,8 @@ require "droonga/catalog/volume_collection"
20
20
  module Droonga
21
21
  module Catalog
22
22
  class Dataset
23
+ DEFAULT_NAME = "Default"
24
+
23
25
  attr_reader :name
24
26
 
25
27
  def initialize(name, data)