solr的守护进程

pro*_*ock 2 solr daemon

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

daemon java -jar start.jar 
Run Code Online (Sandbox Code Playgroud)

它的错误:

daemon: invalid option -- 'j'
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?谢谢.

mli*_*ner 8

下面是一个用于守护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
Run Code Online (Sandbox Code Playgroud)

  • **daemon**没有安装在某些Debian系统上.`sudo apt-get install daemon`应解决此类问题. (3认同)