solr 守护进程 [英] daemon for solr

查看:30
本文介绍了solr 守护进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to run solr with daemon. I saw in another post there is a init.d script you can run but it seems to have problems in my ubuntu environment. whenever i try to run the script with /etc/init.d/solr start or when i try to run the below line manually:

daemon java -jar start.jar 

错误:

daemon: invalid option -- 'j'

有什么想法吗?谢谢.

推荐答案

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

Below is a working script for daemonizing Solr. Couple important notes here:

  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 守护进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆