jmeter服务脚本重新启动无法正常工作

【字号: 日期:2024-04-21浏览:41作者:雯心
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解决jmeter服务脚本重新启动无法正常工作?

您没有JAVA_PID在stop和start命令之间进行重置/更新,因此start将基于以下情况退出:

[ -n '$JAVA_PID' ] && echo '$NAME already started' && exit 0

您需要JAVA_PID在停止后重设/更新,例如

update_pid(){ JAVA_PID=$(pgrep -f '[A]pacheJMeter.jar $RMI_HOST_DEF -Dserver_port=1099')}...do_restart(){ do_stop update_pid do_start}解决方法

我正在尝试在Centos 6.6上将以下服务脚本用于apache jmeter。

#!/bin/sh### BEGIN INIT INFO# chkconfig: 2345 85 15# Provides: jmeter-server# Required-Start: $syslog $local_fs# Required-Stop: $syslog $local_fs# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: Apache JMeter Remote Server# Description: Apache JMeter Remote Server runs JMeter tests issued from a remote server.### END INIT INFO# Author: Brian Flad <bflad417 at gmail dot com>PATH=/sbin:/usr/sbin:/bin:/usr/binNAME=jmeterJMETER_PATH=/usr/share/jmeter# RMI_HOST_DEF is referenced/used inside the $JMETER_PATH/bin/$NAME-server script# Change this to your IPexport RMI_HOST_DEF='-Djava.rmi.server.hostname=10.0.2.15'SCRIPTNAME=/etc/init.d/$NAMEJAVA_PID=$(pgrep -f '[A]pacheJMeter.jar $RMI_HOST_DEF -Dserver_port=1099')# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ '${NETWORKING}' = 'no' ] && exit 0[ -f $JMETER_PATH/bin/$NAME-server ] || exit 0[ -f $JMETER_PATH/bin/$NAME ] || exit 0## Function that starts the daemon/service#do_start(){[ -n '$JAVA_PID' ] && echo '$NAME already started' && exit 0echo -n 'Starting $NAME: '$JMETER_PATH/bin/$NAME-server 2>&1 &RETVAL=$?MODE='normal'echo '$NAME started in $MODE mode'[ $RETVAL = 0 ] && touch /var/lock/subsys/$NAME}## Function that stops the daemon/service#do_stop(){[ -z '$JAVA_PID' ] && echo '$NAME already stopped' && exit 0echo -n 'Shutting down $NAME: 'kill '$JAVA_PID'RETVAL=$?echo 'return is $RETVAL'echo[ $RETVAL = 0 ] && rm -f /var/lock/subsys/$NAME}## Function that gives status of daemon/server#do_status(){if [ -n '$JAVA_PID' ]; then MODE='RUNNING pid $JAVA_PID' RETVAL=0else MODE='STOPPED' RETVAL=1fiecho '$NAME is $MODE'}## Function that stops and restarts daemon/server#do_restart(){do_stopdo_start}case '$1' in start)do_start;; stop)do_stop;; status)do_status;; restart|force-reload)do_restart;; condrestart)[ -e /var/lock/subsys/$NAME ] && do_restart;; *)echo 'Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}' >&2exit 3;;esacexit $RETVAL

service jmeter start和service jmeter stop正常运行,但是当我尝试重新启动servicejmeter时,它正在停止Java实例,但由于认为jmeter已经在运行,因此没有再次启动它。

任何指针将不胜感激。

相关文章: