【问题标题】:daemon for solrsolr 的守护进程
【发布时间】:2010-12-12 02:28:03
【问题描述】:

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

daemon java -jar start.jar 

错误:

daemon: invalid option -- 'j'

有什么想法吗?谢谢。

【问题讨论】:

    标签: solr daemon


    【解决方案1】:

    以下是用于守护 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
    

    【讨论】:

    • 你知道如何在 CentOS 机器上安装守护进程吗?
    • 另外 - 只是想指出我可以以非 root 用户身份运行它,没有任何问题。只需对 Solr 目录中的 DATA 目录执行 CHOWN -R myuser
    • daemon 未安装在某些 Debian 系统上。 sudo apt-get install daemon 应该可以解决此类问题。
    【解决方案2】:

    【讨论】:

    • 不幸的是,jetty 没有实现与 Apache Daemon (jsvc) 一起使用的正确接口
    【解决方案3】:

    试试这个:

    daemon `java -jar start.jar` 
    

    【讨论】:

      猜你喜欢
      • 2023-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 2011-02-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多