I want to set crate boot with the redhat,so I write a systemd service file for crate:
crate version: 1.1.2
following is crate.service:
[Unit]
Description=crate daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/bin/su - hadmin -c '/home/hadmin/aisinofp/crate/bin/crate.sh start'
ExecStop=/usr/bin/su - hadmin -c '/home/hadmin/aisinofp/crate/bin/crate.sh stop'
Restart=always
[Install]
WantedBy=multi-user.target
the crate.sh is:
#!/bin/bash
source /home/hadmin/myproject/conf/env.sh
if [ "$1" = "start" ]
then
$CRATE_HOME/bin/crate -d
elif [ "$1" = "stop" ]
then
pid=$(ps -ef|grep io.crate.bootstrap.CrateDB |grep jar |awk '{print $2}')
echo "KILLING cratedb PROCESS "$pid
kill -9 $pid
fi
the env.sh is:
#!/bin/bash
# set ulimit
#ulimit -n 655360
export JAVA_HOME=/usr/java/default
export JRE_HOME=/usr/java/default
PATH=$JAVA_HOME/bin:$PATH
# environment for all Projects
export TD_BASE=/home/hadmin
export TD_HOME=$TD_BASE/myproject
export TD_DATA=$TD_BASE/data
# zookeeper environment
export ZOO_HOME=$TD_BASE/zookeeper
export ZOO_LOG_DIR=$ZOO_HOME/logs
PATH=$ZOO_HOME/bin:$PATH
# cratedb environment
export CRATE_HEAP_SIZE=4g
export CRATE_HOME=/home/hadmin/crate
PATH=$CRATE_HOME/bin:$PATH
# activemq environment
export activemq_data=/home/hadmin/data/activemq
export activemq_base=/home/hadmin/activemq
export activemq_conf=$activemq_base/conf
PATH=$activemq_base/bin:$PATH
export PATH
when I finish writing these files, I start using "systemctl start crate.service",but I got messages like this in /var/logs/message:
I can see that the crate daemon has being restarting all the time, I don't know why it would be killed after started
thanks