solr 守护进程

发布于 2024-10-07 15:24:03 字数 263 浏览 8 评论 0原文

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

daemon java -jar start.jar 

它错误:

daemon: invalid option -- 'j'

有什么想法吗?谢谢。

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 

it errors:

daemon: invalid option -- 'j'

Any ideas? thx.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

输什么也不输骨气 2024-10-14 15:24:03

下面是一个用于守护 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

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

  1. You need to set the chdir for the daemon script or else you'll get errors loading your config file.
  2. This will allow you to start/stop/status/restart Solr.
  3. This is a simple version that seems to be working for me.

Here's the script:

#!/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
国际总奸 2024-10-14 15:24:03

试试这个:

daemon `java -jar start.jar` 

Try this:

daemon `java -jar start.jar` 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文