Thursday, September 18, 2014

How to start APACHE TIKA file daemon on start or add service

Create file /etc/init.d/tika

nano /etc/init.d/tika

insert follow content


#!/bin/sh
# Starts, stops, and restarts Tika Server.
#
# chkconfig: 35 92 08 description: Starts and stops Tika server
# Written by David Braslavsky

TIKA_DIR="/usr/local/src/tika-1.5/tika-server/target/" JAVA_OPTIONS="-Xmx2048m  -jar tika-server-1.5.jar --hostname=hostname --port=9998"
LOG_FILE="/var/log/tika.log"
JAVA="/usr/bin/java"

case $1 in
    start)
        echo "Starting Tika"
        cd $TIKA_DIR
        $JAVA $JAVA_OPTIONS 2> $LOG_FILE &
        ;;
    stop)
        echo "Stopping Tika server"
        pid=`ps aux | grep tika-server | awk '{print $2}'`
        kill -9 $pid
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}" >&2
        exit 1
        ;;
esac


chmod +x /etc/inid.d/tika

chkconfig --add tika

service tika start


No comments: