gpt4 book ai didi

solr - solr 守护进程

转载 作者:行者123 更新时间:2023-12-04 19:51:33 27 4
gpt4 key购买 nike

我想用守护进程运行 solr。我在另一篇文章中看到有一个可以运行的 init.d 脚本,但它在我的 ubuntu 环境中似乎有问题。每当我尝试使用/etc/init.d/solr start 运行脚本时,或者当我尝试手动运行以下行时:

daemon java -jar start.jar 

错误:

daemon: invalid option -- 'j'

有什么想法吗?谢谢。

最佳答案

下面是一个用于守护 Solr 的工作脚本。这里有几个重要的注意事项:

  1. 您需要为守护程序脚本设置 chdir,否则加载配置文件时会出错。
  2. 这将允许您启动/停止/状态/重新启动 Solr。
  3. 这是一个简单的版本,似乎适合我。

这是脚本:

#!/bin/sh

# Prerequisites:
# 1. Solr needs to be installed at /usr/local/solr/example
# 2. daemon needs to be installed
# 3. Script needs to be executed by root

# This script will launch Solr in a mode that will automatically respawn if it
# crashes. Output will be sent to /var/log/solr/solr.log. A pid file will be
# created in the standard location.

start () {
echo -n "Starting solr..."

# start daemon
daemon --chdir='/usr/local/solr/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose

RETVAL=$?
if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}

stop () {
# stop daemon
echo -n "Stopping solr..."

daemon --stop --name=solr --verbose
RETVAL=$?

if [ $RETVAL = 0 ]
then
echo "done."
else
echo "failed. See error code for more information."
fi
return $RETVAL
}


restart () {
daemon --restart --name=solr --verbose
}


status () {
# report on the status of the daemon
daemon --running --verbose --name=solr
return $?
}


case "$1" in
start)
start
;;
status)
status
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: solr {start|status|stop|restart}"
exit 3
;;
esac

exit $RETVAL

关于solr - solr 守护进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4420127/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com