4

[求助]ActiveMQ Artemis, shell 中可以正常启动,但使用 systemctl start 无法启动

 2 years ago
source link: https://www.v2ex.com/t/847066
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Linux

[求助]ActiveMQ Artemis, shell 中可以正常启动,但使用 systemctl start 无法启动

  pocketz · 13 小时 56 分钟前 · 390 次点击

Artemis 版本:2.19.1
JDK 1.8.0.271

尝试过使用不同权限用户,都无法使用 systemctl start 启动

Shell

使用 broker 中的 artemis-service start ,能够正常启动

systemctl

service 文件如下

[Unit]

Description=Apache ActiveMQ Artemis
After=network.target

[Service]

Type=forking
User=activemq
Group=activemq

ExecStart=/var/lib/jms-broker/bin/artemis-service start
ExecStop=/var/lib/jms-broker/bin/artemis-service stop

[Install]
WantedBy=multi-user.target

journalctl -xe中的 artemis-service 返回的信息很有限,除了 starting ,就只有Could not start ${service}

顺便贴一下 artemis-serive 启动脚本的内容,这个脚本是 artemis 自动生成的

service=`basename "$0"`

#
# Discover the ARTEMIS_INSTANCE from the location of this script.
#
if [ -z "$ARTEMIS_INSTANCE" ] ; then

  ## resolve links - $0 may be a link to ActiveMQ's home
  PRG="$0"
  saveddir=`pwd`

  # need this for relative symlinks
  dirname_prg=`dirname "$PRG"`
  cd "$dirname_prg"

  while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '.*/.*' > /dev/null; then
      PRG="$link"
    else
      PRG=`dirname "$PRG"`"/$link"
    fi
  done

  ARTEMIS_INSTANCE=`dirname "$PRG"`
  cd "$saveddir"

  # make it fully qualified
  ARTEMIS_INSTANCE=`cd "$ARTEMIS_INSTANCE/.." && pwd`
  export ARTEMIS_INSTANCE

fi

PID_FILE="${ARTEMIS_INSTANCE}/data/artemis.pid"

if [ ! -d "${ARTEMIS_INSTANCE}/data/" ]; then
    mkdir "${ARTEMIS_INSTANCE}/data/"
fi

status() {
  if [ -f "${PID_FILE}" ] ; then
    pid=`cat "${PID_FILE}"`
    # check to see if it's gone...
    ps -p ${pid} > /dev/null
    if [ $? -eq 0 ] ; then
      return 0
    else
      rm "${PID_FILE}"
      return 3
    fi
  fi
  return 3
}

stop() {
  if [ -f "${PID_FILE}" ] ; then
    pid=`cat "${PID_FILE}"`
    kill $@ ${pid} > /dev/null
  fi
  for i in 1 2 3 4 5 ; do
    status
    if [ $? -ne 0 ] ; then
      return 0
    fi
    sleep 1
  done
  echo "Could not stop process ${pid}"
  return 1
}

start() {

  status
  if [ $? -eq 0 ] ; then
    echo "Already running."
    return 1
  fi

  if [ -z "$ARTEMIS_USER" -o `id -un` = "$ARTEMIS_USER" ] ; then
    nohup "${ARTEMIS_INSTANCE}/bin/artemis" run > /dev/null 2> /dev/null &
  else
    sudo -n -u ${ARTEMIS_USER} nohup "${ARTEMIS_INSTANCE}/bin/artemis" run > /dev/null 2> /dev/null &
  fi

  echo $! > "${PID_FILE}"

  # check to see if stays up...
  sleep 1
  status
  if [ $? -ne 0 ] ; then
    echo "Could not start ${service}"
    return 1
  fi
  echo "${service} is now running (${pid})"
  return 0
}

case $1 in
  start)
    echo "Starting ${service}"
    start
    exit $?
  ;;

  force-stop)
    echo "Forcibly Stopping ${service}"
    stop -9
    exit $?
  ;;

  stop)
    echo "Gracefully Stopping ${service}"
    stop
    exit $?
  ;;

  restart)
    echo "Restarting ${service}"
    stop
    start
    exit $?
  ;;

  status)
    status
    rc=$?
    if [ $rc -eq 0 ] ; then
      echo "${service} is running (${pid})"
    else
      echo "${service} is stopped"
    fi
    exit $rc
  ;;

  *)
    echo "Usage: $0 {start|stop|restart|force-stop|status}" >&2
    exit 2
  ;;
esac

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK