diff options
author | feld <feld@FreeBSD.org> | 2018-02-22 22:13:30 +0800 |
---|---|---|
committer | feld <feld@FreeBSD.org> | 2018-02-22 22:13:30 +0800 |
commit | 4297f781adc2a861228a184a347024e0e5e23ac1 (patch) | |
tree | 0c356ad4d993f7e134e211a11484ba8609aaa703 /textproc/elasticsearch5 | |
parent | 7e259715f65a6f87f613b9434bd5404604602083 (diff) | |
download | freebsd-ports-gnome-4297f781adc2a861228a184a347024e0e5e23ac1.tar.gz freebsd-ports-gnome-4297f781adc2a861228a184a347024e0e5e23ac1.tar.zst freebsd-ports-gnome-4297f781adc2a861228a184a347024e0e5e23ac1.zip |
textproc/elasticsearch5: rc script improvement
- Fix behavior with multiple profiles
- Correctly handle the individual config dirs
- Prevent thundering herd at shutdown by using wait_for_pids
Approved by: maintainer
MFH: 2018Q1
Diffstat (limited to 'textproc/elasticsearch5')
-rw-r--r-- | textproc/elasticsearch5/Makefile | 2 | ||||
-rw-r--r-- | textproc/elasticsearch5/files/elasticsearch.in | 52 | ||||
-rw-r--r-- | textproc/elasticsearch5/files/patch-bin_elasticsearch.in.sh | 22 |
3 files changed, 28 insertions, 48 deletions
diff --git a/textproc/elasticsearch5/Makefile b/textproc/elasticsearch5/Makefile index c6130b19adac..4ede31eee3f7 100644 --- a/textproc/elasticsearch5/Makefile +++ b/textproc/elasticsearch5/Makefile @@ -3,7 +3,7 @@ PORTNAME= elasticsearch PORTVERSION= 5.3.0 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= textproc java devel MASTER_SITES= https://artifacts.elastic.co/downloads/${PORTNAME}/ \ http://mirrors.rit.edu/zi/ diff --git a/textproc/elasticsearch5/files/elasticsearch.in b/textproc/elasticsearch5/files/elasticsearch.in index f6a2496c82bd..925a3066dc37 100644 --- a/textproc/elasticsearch5/files/elasticsearch.in +++ b/textproc/elasticsearch5/files/elasticsearch.in @@ -15,7 +15,7 @@ # Set it to required username. # elasticsearch_group (group): Set to elasticsearch by default. # Set it to required group. -# elasticsearch_config (path): Set to /usr/local/etc/elasticsearch/elasticsearch.yml by default. +# elasticsearch_config (path): Set to %%PREFIX%%/etc/elasticsearch/elasticsearch.yml by default. # Set it to the config file location. # elasticsearch_tmp (path): Set to /var/tmp/elasticsearch by default. # Set it to the path to be used for temp files. @@ -27,31 +27,30 @@ rcvar=elasticsearch_enable load_rc_config ${name} -: ${elasticsearch_enable:="NO"} -: ${elasticsearch_user:=%%SEARCHUSER%%} -: ${elasticsearch_group:=%%SEARCHGROUP%%} -: ${elasticsearch_config:="%%PREFIX%%/etc/elasticsearch"} -: ${elasticsearch_tmp:="/var/tmp/elasticsearch"} +: ${elasticsearch_enable:=NO} +: ${elasticsearch_user=elasticsearch} +: ${elasticsearch_group=elasticsearch} +: ${elasticsearch_config=%%PREFIX%%/etc/elasticsearch} +: ${elasticsearch_tmp=/var/tmp/elasticsearch} required_files="${elasticsearch_config}/elasticsearch.yml" -_pidprefix="/var/run/elasticsearch" -pidfile="${_pidprefix}.pid" +_pidprefix=/var/run/elasticsearch +pidfile=${_pidprefix}.pid extra_commands="console status" -console_cmd="elasticsearch_console" -start_precmd="elasticsearch_precmd" -status_cmd="elasticsearch_status" -stop_cmd="elasticsearch_stop" -command="%%PREFIX%%/lib/elasticsearch/bin/elasticsearch" -command_args="-d --pidfile=${pidfile}" +console_cmd=elasticsearch_console +start_precmd=elasticsearch_precmd +status_cmd=elasticsearch_status +stop_cmd=elasticsearch_stop +command=%%PREFIX%%/lib/elasticsearch/bin/elasticsearch +command_args="-d --pidfile=${pidfile} -Epath.conf=${elasticsearch_config}" elasticsearch_precmd() { - touch ${pidfile} - chown ${elasticsearch_user}:${elasticsearch_group} ${pidfile} - /usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 750 ${elasticsearch_tmp} - /usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 750 /var/db/elasticsearch - /usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 750 /var/log/elasticsearch + /usr/bin/install -o ${elasticsearch_user} -g ${elasticsearch_group} /dev/null ${pidfile} + /usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 755 ${elasticsearch_tmp} + /usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 755 /var/db/elasticsearch + /usr/bin/install -d -o ${elasticsearch_user} -g ${elasticsearch_group} -m 755 /var/log/elasticsearch } elasticsearch_console() @@ -60,7 +59,6 @@ elasticsearch_console() run_rc_command "start" } - elasticsearch_stop() { rc_pid=$(elasticsearch_check_pidfile $pidfile) @@ -72,7 +70,8 @@ elasticsearch_stop() fi echo "Stopping ${name}." - kill ${rc_pid} 2> /dev/null + kill $sig_stop ${rc_pid} + wait_for_pids ${rc_pid} } elasticsearch_status() @@ -102,15 +101,13 @@ elasticsearch_check_pidfile() debug "pid file ($_pidfile): no pid in file." return fi - if [ -n "`%%LOCALBASE%%/bin/jps -l | grep -e "^$_pid"`" ]; then + if [ -n "`%%PREFIX%%/bin/jps -l | grep -e "^$_pid"`" ]; then echo -n $_pid fi } if [ -n "$2" ]; then profile="$2" if [ "x${elasticsearch_profiles}" != "x" ]; then - pidfile="${_pidprefix}.${profile}.pid" - command_args="-d --pidfile=${pidfile}" eval elasticsearch_config="\${elasticsearch_${profile}_config:-}" if [ "x${elasticsearch_config}" = "x" ]; then echo "You must define a configuration (elasticsearch_${profile}_config)" @@ -120,6 +117,11 @@ if [ -n "$2" ]; then required_files="${elasticsearch_config}/jvm.options" eval elasticsearch_enable="\${elasticsearch_${profile}_enable:-${elasticsearch_enable}}" eval elasticsearch_tmp="\${elasticsearch_${profile}_args:-${elasticsearch_tmp}}" + pidfile="${_pidprefix}.${profile}.pid" + if [ -e ${elasticsearch_config}/jvm.options ]; then + export ES_JVM_OPTIONS=${elasticsearch_config}/jvm.options + fi + command_args="-d --pidfile=${pidfile} -Epath.conf=${elasticsearch_config}" else echo "$0: extra argument ignored" fi @@ -147,7 +149,7 @@ else ;; esac echo "===> elasticsearch profile: ${profile}" - /usr/local/etc/rc.d/elasticsearch $1 ${profile} + %%PREFIX%%/etc/rc.d/elasticsearch $1 ${profile} retcode="$?" if [ "0${retcode}" -ne 0 ]; then failed="${profile} (${retcode}) ${failed:-}" diff --git a/textproc/elasticsearch5/files/patch-bin_elasticsearch.in.sh b/textproc/elasticsearch5/files/patch-bin_elasticsearch.in.sh deleted file mode 100644 index 3a95104c81ca..000000000000 --- a/textproc/elasticsearch5/files/patch-bin_elasticsearch.in.sh +++ /dev/null @@ -1,22 +0,0 @@ ---- bin/elasticsearch.in.sh.orig 2016-11-24 10:05:27 UTC -+++ bin/elasticsearch.in.sh -@@ -1,5 +1,19 @@ - #!/bin/bash - -+if [ `uname -o` == "FreeBSD" ]; then -+ . /etc/rc.subr -+ load_rc_config elasticsearch -+ ES_MIN_MEM=${elasticsearch_min_mem} -+ ES_MAX_MEM=${elasticsearch_max_mem} -+ ES_HEAP_NEW_SIZE=${elasticsearch_heap_newsize} -+ ES_DIRECT_SIZE=${elasticsearch_direct_size} -+ ES_USE_IPV4=${elasticsearch_use_ipv4} -+ ES_GC_OPTS=${elasticsearch_gc_opts} -+ ES_GC_LOG_FILE=${elasticsearch_gc_logfile} -+ ES_JAVA_OPTS="$ES_JAVA_OPTS -Des.path.conf=${elasticsearch_config:="/usr/local/etc/elasticsearch"}" -+ PATH=${PATH}:/usr/local/bin -+fi -+ - # check in case a user was using this mechanism - if [ "x$ES_CLASSPATH" != "x" ]; then - cat >&2 << EOF |