2015-01-08 2 views
1

solr을 /etc/init.d/solr의 시작 스크립트로 실행하려고합니다. 이 위의 링크에 설명 된대로 내가 How to start Solr automatically?데몬과 같은 solr 실행

#!/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. 

# Comments to support chkconfig on Red Hat Linux 
# chkconfig: 2345 64 36 
# Description: A very fast and reliable search engine. 
# processname solr 

# Source function library. 
. /etc/init.d/functions 

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 

내가 모든 것을 한에서 copypasted 스크립트입니다. 그러나 데몬 스크립트가 게시 된 경우 (/etc/init.d/functions에서)를 daemon 기능 (2010 년부터 변경 되었기 때문에

답변

0

이 작동하지 않는 잘못된 기록 된 이유를 이해하지 못하는 오류

service solr start 
Starting solr.../etc/init.d/solr: Usage: daemon [+/-nicelevel] {program} 
failed. See error code for more information. 

https://blog.hazrulnizam.com/create-init-script-centos-6/ 읽기를 얻을 수) 더 이상 동일한 인수를 허용하지 않습니다. 현재 지원되는 인수를 사용하려면 daemon 행을 다시 작성해야합니다.

은 내가 CentOS는 6 상자의 daemon 기능을 살펴했고,이 라인을 대체 할 수있을 것 같습니다 : 그냥이 함께

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

을 :

daemon "java -jar /usr/local/solr/example/start.jar" 

(solr/usr/local/solr/example에 설치되어 있다고 가정합니다.

관련 문제