From owner-svn-ports-all@freebsd.org Thu Feb 22 23:03:42 2018 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ECD19F0AD2A; Thu, 22 Feb 2018 23:03:41 +0000 (UTC) (envelope-from feld@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A29537DFCC; Thu, 22 Feb 2018 23:03:41 +0000 (UTC) (envelope-from feld@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9D74C6553; Thu, 22 Feb 2018 23:03:41 +0000 (UTC) (envelope-from feld@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1MN3fRO001911; Thu, 22 Feb 2018 23:03:41 GMT (envelope-from feld@FreeBSD.org) Received: (from feld@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1MN3faf001909; Thu, 22 Feb 2018 23:03:41 GMT (envelope-from feld@FreeBSD.org) Message-Id: <201802222303.w1MN3faf001909@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: feld set sender to feld@FreeBSD.org using -f From: Mark Felder Date: Thu, 22 Feb 2018 23:03:41 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r462650 - in head/textproc/elasticsearch5: . files X-SVN-Group: ports-head X-SVN-Commit-Author: feld X-SVN-Commit-Paths: in head/textproc/elasticsearch5: . files X-SVN-Commit-Revision: 462650 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Feb 2018 23:03:42 -0000 Author: feld Date: Thu Feb 22 23:03:41 2018 New Revision: 462650 URL: https://svnweb.freebsd.org/changeset/ports/462650 Log: textproc/elasticsearch5: Use native facilites for manging the process start/stop/status will behave correctly with procname set. This now prevents Elastic from starting when a process is already running, stops cleanly, and also handles multiple profiles correctly: if only some of the profile processes are running, a "service elasticsearch start" will only start the profiles that are not detected as running already. All of this comes with the caveat that Elastic is slow to start up and write its pidfile, so if you are too quick it will allow duplicate processes to start. Here be JVM dragons. Approved by: portmgr (with hat) MFH: 2018Q1 Modified: head/textproc/elasticsearch5/Makefile head/textproc/elasticsearch5/files/elasticsearch.in Modified: head/textproc/elasticsearch5/Makefile ============================================================================== --- head/textproc/elasticsearch5/Makefile Thu Feb 22 22:59:37 2018 (r462649) +++ head/textproc/elasticsearch5/Makefile Thu Feb 22 23:03:41 2018 (r462650) @@ -3,7 +3,7 @@ PORTNAME= elasticsearch PORTVERSION= 5.3.0 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= textproc java devel MASTER_SITES= https://artifacts.elastic.co/downloads/${PORTNAME}/ \ http://mirrors.rit.edu/zi/ @@ -51,7 +51,8 @@ ELASTIC_LOGDIR= /var/log/elasticsearch SUB_LIST= SEARCHUSER=${SEARCHUSER} \ SEARCHGROUP=${SEARCHGROUP} \ - PORTVERSION=${PORTVERSION} + PORTVERSION=${PORTVERSION} \ + JAVA=${JAVA} SUB_FILES= pkg-message PLIST_SUB+= SEARCHUSER=${SEARCHUSER} \ SEARCHGROUP=${SEARCHGROUP} \ Modified: head/textproc/elasticsearch5/files/elasticsearch.in ============================================================================== --- head/textproc/elasticsearch5/files/elasticsearch.in Thu Feb 22 22:59:37 2018 (r462649) +++ head/textproc/elasticsearch5/files/elasticsearch.in Thu Feb 22 23:03:41 2018 (r462650) @@ -36,12 +36,11 @@ load_rc_config ${name} required_files="${elasticsearch_config}/elasticsearch.yml" _pidprefix=/var/run/elasticsearch pidfile=${_pidprefix}.pid +procname=%%JAVA%% 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} -Epath.conf=${elasticsearch_config}" @@ -59,52 +58,6 @@ elasticsearch_console() run_rc_command "start" } -elasticsearch_stop() -{ - rc_pid=$(elasticsearch_check_pidfile $pidfile) - - if [ -z "$rc_pid" ]; then - [ -n "$rc_fast" ] && return 0 - echo "${name} not running? (check $pidfile)." - return 1 - fi - - echo "Stopping ${name}." - kill $sig_stop ${rc_pid} - wait_for_pids ${rc_pid} -} - -elasticsearch_status() -{ - rc_pid=$(elasticsearch_check_pidfile $pidfile) - - if [ -z "$rc_pid" ]; then - [ -n "$rc_fast" ] && return 0 - echo "${name} not running? (check $pidfile)." - return 1 - fi - echo "${name} is running as pid ${rc_pid}." -} - -elasticsearch_check_pidfile() -{ - _pidfile=$1 - if [ -z "$_pidfile" ]; then - err 3 'USAGE: elasticsearch_check_pidfile pidfile' - fi - if [ ! -f $_pidfile ]; then - debug "pid file ($_pidfile): not readable." - return - fi - read _pid _junk < $_pidfile - if [ -z "$_pid" ]; then - debug "pid file ($_pidfile): no pid in file." - return - fi - 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