BIGTOP-935. Use init script templates for hive
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/a3537219 Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/a3537219 Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/a3537219 Branch: refs/heads/master Commit: a3537219bd0e6a880f23ed54f6db39f6bf58b96f Parents: e4e85d1 Author: Sean Mackrory <[email protected]> Authored: Tue Apr 23 10:19:39 2013 -0700 Committer: Roman Shaposhnik <[email protected]> Committed: Wed May 1 16:56:40 2013 -0700 ---------------------------------------------------------------------- bigtop-packages/src/common/hive/hive-metastore.svc | 72 +++++ bigtop-packages/src/common/hive/hive-server.svc | 72 +++++ bigtop-packages/src/common/hive/hive.sh | 164 ----------- bigtop-packages/src/common/hive/hive.sh.suse | 221 --------------- .../src/deb/hive/install_init_scripts.sh | 34 --- bigtop-packages/src/deb/hive/rules | 4 +- bigtop-packages/src/deb/hive/service-init.d.tpl | 167 ----------- bigtop-packages/src/rpm/hive/SPECS/hive.spec | 12 +- 8 files changed, 152 insertions(+), 594 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive-metastore.svc ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/hive/hive-metastore.svc b/bigtop-packages/src/common/hive/hive-metastore.svc new file mode 100644 index 0000000..10a9a62 --- /dev/null +++ b/bigtop-packages/src/common/hive/hive-metastore.svc @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +DAEMON="hive-metastore" +DESC="Hive Metastore" +EXEC_PATH="/usr/lib/hive/bin/hive" +SVC_USER="hive" +DAEMON_FLAGS="" +CONF_DIR="/etc/hive/conf" +PIDFILE="/var/run/hive/${DAEMON}.pid" +LOCKDIR="/var/lock/subsys" +LOCKFILE="${DAEMON}" + +generate_start() { + +cat <<'__EOT__' +start() { + [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED + log_success_msg "Starting $DESC (${DAEMON}): " + + checkstatusofproc + status=$? + if [ "$status" -eq "$STATUS_RUNNING" ]; then + log_success_msg "${DESC} is running" + exit 0 + fi + + LOG_FILE=/var/log/hive/${DAEMON}.out + + exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${DAEMON}.log -Dhive.log.threshold=INFO\"" + + su -s /bin/sh $SVC_USER -c "$exec_env nohup nice -n 0 \ + $EXEC_PATH --service metastore $PORT \ + > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PIDFILE" + sleep 3 + + checkstatusofproc + RETVAL=$? + [ $RETVAL -eq $STATUS_RUNNING ] && touch $LOCKFILE + return $RETVAL +} +__EOT__ + +} + +generate_stop() { + +cat <<'__EOT__' +stop() { + log_success_msg "Stopping $DESC (${DAEMON}): " + killproc -p $PIDFILE java + RETVAL=$? + + [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE + return $RETVAL +} +__EOT__ + +} + http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive-server.svc ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/hive/hive-server.svc b/bigtop-packages/src/common/hive/hive-server.svc new file mode 100644 index 0000000..049e814 --- /dev/null +++ b/bigtop-packages/src/common/hive/hive-server.svc @@ -0,0 +1,72 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +DAEMON="hive-server" +DESC="Hive Server" +EXEC_PATH="/usr/lib/hive/bin/hive" +SVC_USER="hive" +DAEMON_FLAGS="" +CONF_DIR="/etc/hive/conf" +PIDFILE="/var/run/hive/${DAEMON}.pid" +LOCKDIR="/var/lock/subsys" +LOCKFILE="${DAEMON}" + +generate_start() { + +cat <<'__EOT__' +start() { + [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED + log_success_msg "Starting $DESC (${DAEMON}): " + + checkstatusofproc + status=$? + if [ "$status" -eq "$STATUS_RUNNING" ]; then + log_success_msg "${DESC} is running" + exit 0 + fi + + LOG_FILE=/var/log/hive/${DAEMON}.out + + exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${DAEMON}.log -Dhive.log.threshold=INFO\"" + + su -s /bin/sh $SVC_USER -c "$exec_env nohup nice -n 0 \ + $EXEC_PATH --service hiveserver $PORT \ + > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PIDFILE" + sleep 3 + + checkstatusofproc + RETVAL=$? + [ $RETVAL -eq $STATUS_RUNNING ] && touch $LOCKFILE + return $RETVAL +} +__EOT__ + +} + +generate_stop() { + +cat <<'__EOT__' +stop() { + log_success_msg "Stopping $DESC (${DAEMON}): " + killproc -p $PIDFILE java + RETVAL=$? + + [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE + return $RETVAL +} +__EOT__ + +} + http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive.sh ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/hive/hive.sh b/bigtop-packages/src/common/hive/hive.sh deleted file mode 100755 index 0a61453..0000000 --- a/bigtop-packages/src/common/hive/hive.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# -# -# -# Starts a Hive @HIVE_DAEMON@ -# -# chkconfig: 345 90 10 -# description: Starts a Hive @HIVE_DAEMON@ -# processname: hive -# pidfile: /var/run/hive/hive-@[email protected] -### BEGIN INIT INFO -# Provides: hive-@HIVE_DAEMON@ -# Required-Start: $syslog $remote_fs -# Should-Start: -# Required-Stop: $syslog $remote_fs -# Should-Stop: -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Starts a Hive @HIVE_DAEMON@ -### END INIT INFO - -source /lib/lsb/init-functions - -# Autodetect JAVA_HOME if not defined -. /usr/lib/bigtop-utils/bigtop-detect-javahome - -RETVAL_SUCCESS=0 - -STATUS_RUNNING=0 -STATUS_DEAD=1 -STATUS_DEAD_AND_LOCK=2 -STATUS_NOT_RUNNING=3 - -ERROR_PROGRAM_NOT_INSTALLED=5 -ERROR_PROGRAM_NOT_CONFIGURED=6 - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -NAME="hive-@HIVE_DAEMON@" -DESC="Hive @HIVE_DAEMON@ daemon" -SYS_FILE="/etc/default/${NAME}" -EXE_FILE="/usr/lib/hive/bin/hive" -PID_FILE="/var/run/hive/${NAME}.pid" -LOCKFILE="/var/lock/subsys/${NAME}" -LOG_FILE="/var/log/hive/${NAME}.out" -HIVE_USER="hive" -HIVE_HOME="`eval echo ~$HIVE_USER`" -NICENESS="+0" -TIMEOUT=3 -USER="hive" - -[ -f $SYS_FILE ] && . $SYS_FILE - -hive_start() { - [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED - - exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${NAME}.log -Dhive.log.threshold=INFO\"" - service_name="@HIVE_DAEMON@" - if [ $service_name = "server" ] ; then - service_name="hiveserver" - fi - - if [ -x /sbin/runuser ]; then - SU="runuser -s /bin/bash $USER" - else - SU="su -s /bin/sh $USER" - fi - - log_success_msg "Starting $desc (${NAME}): " - $SU -c "cd $HIVE_HOME ; $exec_env nohup \ - $EXE_FILE --service $service_name $PORT \ - > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PID_FILE" - - RETVAL=$? - [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE - return $RETVAL -} - -hive_stop() { - log_success_msg "Stopping $desc (${NAME}): " - killproc -p $PID_FILE java - RETVAL=$? - - [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PID_FILE - return $RETVAL -} - -hive_restart() { - hive_stop - [ -n "$TIMEOUT" ] && sleep $TIMEOUT - hive_start -} - -hive_status() { - echo -n "Checking for service $desc: " - pidofproc -p $PID_FILE java > /dev/null - status=$? - - case "$status" in - $STATUS_RUNNING) - log_success_msg "@HIVE_DAEMON@ is running" - ;; - $STATUS_DEAD) - log_failure_msg "@HIVE_DAEMON@ is dead and pid file exists" - ;; - $STATUS_DEAD_AND_LOCK) - log_failure_msg "@HIVE_DAEMON@ is dead and lock file exists" - ;; - $STATUS_NOT_RUNNING) - log_failure_msg "@HIVE_DAEMON@ is not running" - ;; - *) - log_failure_msg "@HIVE_DAEMON@ status is unknown" - ;; - esac - return $status -} - -RETVAL=0 - -case "$1" in - start) - hive_start - ;; - - stop|force-stop) - hive_stop - ;; - - force-reload|condrestart|try-restart) - [ -e $LOCKFILE ] && hive_restart || : - ;; - - restart|reload) - hive_restart - ;; - - status) - hive_status - ;; - - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|reload|condrestart|try-restart|force-reload|status|force-stop}" >&2 - - exit 1 - ;; -esac - -exit $RETVAL http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/common/hive/hive.sh.suse ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/hive/hive.sh.suse b/bigtop-packages/src/common/hive/hive.sh.suse deleted file mode 100644 index e079481..0000000 --- a/bigtop-packages/src/common/hive/hive.sh.suse +++ /dev/null @@ -1,221 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -# Starts a Hive @HIVE_DAEMON@ -# -# chkconfig: 345 90 10 -# description: Starts a Hive @HIVE_DAEMON@ -# processname: hive -# -### BEGIN INIT INFO -# Provides: hive-@HIVE_DAEMON@ -# Required-Start: $syslog $remote_fs -# Should-Start: -# Required-Stop: $syslog $remote_fs -# Should-Stop: -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Hive @HIVE_DAEMON@ -### END INIT INFO - -. /lib/lsb/init-functions - -# Autodetect JAVA_HOME if not defined -. /usr/lib/bigtop-utils/bigtop-detect-javahome - -# Modelled after $HADOOP_HOME/bin/hadoop-daemon.sh - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -NAME="hive-@HIVE_DAEMON@" -SYS_FILE="/etc/default/${NAME}" -EXE_FILE="/usr/lib/hive/bin/hive" -PID_FILE="/var/run/hive/${NAME}.pid" -LOCKFILE="/var/lock/subsys/${NAME}" -LOG_FILE="/var/log/hive/${NAME}.out" -HIVE_USER="hive" -NICENESS="0" -DESC="Hive daemon" - -DODTIME=3 -SLAVE_TIMEOUT=300 - -[ -f $SYS_FILE ] && . $SYS_FILE - -hive_die() { - echo "$@" - exit 1 -} -hive_is_process_alive() { - local pid="$1" - kill -0 $pid > /dev/null 2>&1 -} -hive_check_pidfile() { - local pidfile="$1" # IN - local pid - - pid=`cat "$pidfile" 2>/dev/null` - if [ "$pid" = '' ]; then - # The file probably does not exist or is empty. - return 1 - fi - - set -- $pid - pid="$1" - - hive_is_process_alive $pid -} -hive_process_kill() { - local pid="$1" # IN - local signal="$2" # IN - local second - - kill -$signal $pid 2>/dev/null - - for second in 0 1 2 3 4 5 6 7 8 9 10; do - hive_is_process_alive "$pid" || return 0 - sleep 1 - done - - return 1 -} -hive_stop_pidfile() { - local pidfile="$1" # IN - local pid - - pid=`cat "$pidfile" 2>/dev/null` - if [ "$pid" = '' ]; then - # The file probably does not exist or is empty. Success - return 0 - fi - - set -- $pid - pid="$1" - - # First try the easy way - if hive_process_kill "$pid" 15; then - return 0 - fi - - # Otherwise try the hard way - if hive_process_kill "$pid" 9; then - return 0 - fi - - return 1 -} - -hive_start() { - ERROR_PROGRAM_NOT_INSTALLED=5 - - [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED - log_success_msg "Starting $desc (${NAME}): " - - if hive_check_pidfile $PID_FILE ; then - exit 0 - fi - - exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${NAME}.log -Dhive.log.threshold=INFO\"" - service_name="@HIVE_DAEMON@" - if [ $service_name = "server" ] ; then - service_name="hiveserver" - fi - su -s /bin/sh $HIVE_USER \ - -c "$exec_env nohup nice -n $NICENESS \ - $EXE_FILE --service $service_name $PORT \ - > $LOG_FILE 2>&1 < /dev/null & "'echo $! '"> $PID_FILE" - sleep 3 - - hive_check_pidfile $PID_FILE - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch $LOCKFILE - return $RETVAL -} -hive_stop() { - log_success_msg "Stopping $desc (${NAME}): " - if [ -f $PID_FILE ]; then - hive_stop_pidfile $PID_FILE - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f $LOCKFILE $PID_FILE - fi -} -hive_restart() { - hive_stop - [ -n "$DODTIME" ] && sleep $DODTIME - hive_start -} -hive_status() { - local STATUS_RUNNING=0 - local STATUS_DEAD=1 - local STATUS_DEAD_AND_LOCK=2 - local STATUS_NOT_RUNNING=3 - local DAEMON="${NAME}" - - pidofproc -p $PID_FILE java > /dev/null - status=$? - - case "$status" in - $STATUS_RUNNING) - log_success_msg "$DAEMON is running" - ;; - $STATUS_DEAD) - log_failure_msg "$DAEMON is dead and pid file exists" - ;; - $STATUS_DEAD_AND_LOCK) - log_failure_msg "$DAEMON is dead and lock file exists" - ;; - $STATUS_NOT_RUNNING) - log_failure_msg "$DAEMON is not running" - ;; - *) - log_failure_msg "$DAEMON status is unknown" - ;; - esac - return $status -} - -case "$1" in - start) - hive_start - ;; - - stop|force-stop) - hive_stop - ;; - - force-reload|condrestart|try-restart) - [ -e $LOCKFILE ] && hive_restart || : - ;; - - restart|reload) - hive_restart - ;; - - status) - hive_status - ;; - - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|reload|condrestart|try-restart|force-reload|status|force-stop}" >&2 - - exit 1 - ;; -esac - -exit $RETVAL http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/deb/hive/install_init_scripts.sh ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/deb/hive/install_init_scripts.sh b/bigtop-packages/src/deb/hive/install_init_scripts.sh deleted file mode 100755 index 6c9e789..0000000 --- a/bigtop-packages/src/deb/hive/install_init_scripts.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - - -SRC_PKG=hive -for node in server metastore ; do - service_pkgdir=debian/$SRC_PKG-$node - debdir=$service_pkgdir/DEBIAN - template="debian/service-init.d.tpl" - - mkdir -p $service_pkgdir/etc/init.d/ $service_pkgdir/etc/default/ $debdir - cp debian/$SRC_PKG-${node}.default $service_pkgdir/etc/default/$SRC_PKG-$node - sed -e "s|@HIVE_DAEMON@|$node|" $template > $service_pkgdir/etc/init.d/$SRC_PKG-$node - sed -e "s|@HIVE_DAEMON@|$node|" debian/service-postinst.tpl > $debdir/postinst - sed -e "s|@HIVE_DAEMON@|$node|" debian/service-postrm.tpl > $debdir/postrm - chmod 755 $debdir/postinst $debdir/postrm $service_pkgdir/etc/init.d* - - mkdir -p $service_pkgdir/usr/share/lintian/overrides - echo "$SRC_PKG-$node: new-package-should-close-itp-bug" > $service_pkgdir/usr/share/lintian/overrides/$SRC_PKG-$node - -done http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/deb/hive/rules ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/deb/hive/rules b/bigtop-packages/src/deb/hive/rules index 85289ca..a1d4f1c 100755 --- a/bigtop-packages/src/deb/hive/rules +++ b/bigtop-packages/src/deb/hive/rules @@ -33,8 +33,8 @@ override_dh_auto_build: bash debian/do-component-build -Divy.home=${HOME}/.ivy2 touch $@ -server metastore: debian/service-init.d.tpl - sed -e "s|@HIVE_DAEMON@|$@|" $< > debian/${hive_pkg_name}[email protected] +server metastore: + bash debian/init.d.tmpl debian/[email protected] deb debian/${hive_pkg_name}[email protected] override_dh_auto_install: metastore server cp debian/hive-site.xml . http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/deb/hive/service-init.d.tpl ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/deb/hive/service-init.d.tpl b/bigtop-packages/src/deb/hive/service-init.d.tpl deleted file mode 100644 index 0473cbb..0000000 --- a/bigtop-packages/src/deb/hive/service-init.d.tpl +++ /dev/null @@ -1,167 +0,0 @@ -#! /bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -# skeleton example file to build /etc/init.d/ scripts. -# This file should be used to construct scripts for /etc/init.d. -# -# Written by Miquel van Smoorenburg <[email protected]>. -# Modified for Debian -# by Ian Murdock <[email protected]>. -# Further changes by Javier Fernandez-Sanguino <[email protected]> -# -# Starts a Hive @HIVE_DAEMON@ -# -# chkconfig: 345 85 15 -# description: Starts a Hive @HIVE_DAEMON@ -# processname: hive -# -### BEGIN INIT INFO -# Provides: hive-@HIVE_DAEMON@ -# Required-Start: $syslog $remote_fs -# Should-Start: -# Required-Stop: $syslog $remote_fs -# Should-Stop: -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Starts a Hive @HIVE_DAEMON@ -### END INIT INFO - -source /lib/lsb/init-functions - -# Autodetect JAVA_HOME if not defined -. /usr/lib/bigtop-utils/bigtop-detect-javahome - -RETVAL_SUCCESS=0 - -STATUS_RUNNING=0 -STATUS_DEAD=1 -STATUS_DEAD_AND_LOCK=2 -STATUS_NOT_RUNNING=3 -STATUS_DEBIAN_NOT_RUNNING=4 - -ERROR_PROGRAM_NOT_INSTALLED=5 -ERROR_PROGRAM_NOT_CONFIGURED=6 - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -NAME="hive-@HIVE_DAEMON@" -DESC="Hive @HIVE_DAEMON@ daemon" -SYS_FILE="/etc/default/${NAME}" -EXE_FILE="/usr/lib/hive/bin/hive" -PID_FILE="/var/run/hive/${NAME}.pid" -LOCKFILE="/var/lock/subsys/${NAME}" -LOG_FILE="/var/log/hive/${NAME}.out" -HIVE_USER="hive" -HIVE_HOME="`eval echo ~$HIVE_USER`" -NICENESS="+0" -TIMEOUT=3 - -install -d -m 0755 -o ${HIVE_USER} -g ${HIVE_USER} `dirname ${PID_FILE}` - -[ -f $SYS_FILE ] && . $SYS_FILE - -hive_start() { - [ -x $EXE_FILE ] || exit $ERROR_PROGRAM_NOT_INSTALLED - - exec_env="HADOOP_OPTS=\"-Dhive.log.dir=`dirname $LOG_FILE` -Dhive.log.file=${NAME}.log -Dhive.log.threshold=INFO\"" - service_name="@HIVE_DAEMON@" - if [ $service_name = "server" ] ; then - service_name="hiveserver" - fi - - log_success_msg "Starting $desc (${NAME}): " - /sbin/start-stop-daemon --quiet --oknodo --start --user $HIVE_USER --name java --background \ - --chuid $HIVE_USER --nicelevel $NICENESS --chdir $HIVE_HOME \ - --make-pidfile --pidfile $PID_FILE --startas /bin/sh -- \ - -c "$exec_env exec $EXE_FILE --service $service_name $PORT > $LOG_FILE 2>&1 < /dev/null" - - RETVAL=$? - [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE - return $RETVAL -} - -hive_stop() { - log_success_msg "Stopping $desc (${NAME}): " - killproc -p $PID_FILE java - RETVAL=$? - - [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PID_FILE - return $RETVAL -} - -hive_restart() { - hive_stop - [ -n "$TIMEOUT" ] && sleep $TIMEOUT - hive_start -} - -hive_status() { - echo -n "Checking for service $desc: " - pidofproc -p $PID_FILE java > /dev/null - RETVAL=$? - - case "$RETVAL" in - $STATUS_RUNNING) - log_success_msg "@HIVE_DAEMON@ is running" - ;; - $STATUS_DEAD) - log_failure_msg "@HIVE_DAEMON@ is dead and pid file exists" - ;; - $STATUS_DEAD_AND_LOCK) - log_failure_msg "@HIVE_DAEMON@ is dead and lock file exists" - ;; - $STATUS_NOT_RUNNING|$STATUS_DEBIAN_NOT_RUNNING) - log_failure_msg "@HIVE_DAEMON@ is not running" - ;; - *) - log_failure_msg "@HIVE_DAEMON@ status is unknown" - ;; - esac - return $RETVAL -} - -RETVAL=0 - -case "$1" in - start) - hive_start - ;; - - stop|force-stop) - hive_stop - ;; - - force-reload|condrestart|try-restart) - [ -e $LOCKFILE ] && hive_restart || : - ;; - - restart|reload) - hive_restart - ;; - - status) - hive_status - ;; - - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|reload|condrestart|try-restart|force-reload|status|force-stop}" >&2 - - exit 1 - ;; -esac - -exit $RETVAL http://git-wip-us.apache.org/repos/asf/bigtop/blob/a3537219/bigtop-packages/src/rpm/hive/SPECS/hive.spec ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/rpm/hive/SPECS/hive.spec b/bigtop-packages/src/rpm/hive/SPECS/hive.spec index 1fbb3d1..f700d89 100644 --- a/bigtop-packages/src/rpm/hive/SPECS/hive.spec +++ b/bigtop-packages/src/rpm/hive/SPECS/hive.spec @@ -63,12 +63,14 @@ BuildArch: noarch Source0: %{name}-%{hive_base_version}.tar.gz Source1: do-component-build Source2: install_hive.sh -Source3: hive.sh +Source3: init.d.tmpl Source4: hive-site.xml Source5: hive-server.default Source6: hive-metastore.default Source7: hive.1 Source8: hive-site.xml +Source9: hive-server.svc +Source10: hive-metastore.svc Requires: hadoop-client, bigtop-utils >= 0.6, hbase, zookeeper Obsoletes: %{name}-webinterface @@ -142,7 +144,6 @@ cp $RPM_SOURCE_DIR/hive-site.xml . --build-dir=%{hive_dist} \ --doc-dir=%{doc_hive} -%__install -d -m 0755 $RPM_BUILD_ROOT/%{initd_dir}/ %__install -d -m 0755 $RPM_BUILD_ROOT/etc/default/ %__install -m 0644 %{SOURCE6} $RPM_BUILD_ROOT/etc/default/%{name}-metastore %__install -m 0644 %{SOURCE5} $RPM_BUILD_ROOT/etc/default/%{name}-server @@ -159,10 +160,9 @@ cp $RPM_SOURCE_DIR/hive-site.xml . for service in %{hive_services} do - init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service} - %__cp %{SOURCE3} $init_file - %__sed -i -e "s|@HIVE_DAEMON@|${service}|" $init_file - chmod 755 $init_file + # Install init script + init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service} + bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/hive-${service}.svc rpm $init_file done %pre
