seata开机自启动

2021-06-28  本文已影响0人  黑白蓝调
  1. cd /etc/init.d 进入目录
  2. 创建文件seata
#!/bin/bash
#
#chkconfig: 345 63 37
#description: seata
#processname: seata


export NODE_HOME=/usr/local/node-v15.5.0-linux-x64
export JAVA_HOME=/usr/local/jdk1.8.0_271
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export NODE_PATH=$NODE_HOME/lib/node_modules
export PATH=$PWD/bin:/usr/local/openresty/nginx/sbin:$JAVA_HOME/bin:$NODE_HOME/bin:$PATH

SEATA_HOME=/usr/local/seata

case $1 in
  start)
    nohup sh $SEATA_HOME/bin/seata-server.sh -p 8091 -h 192.168.116.135 > seata.out 2>&1 &
        echo $! > $SEATA_HOME/bin/seata.pid
    echo "seata is started"
    ;;
  stop)
    pid=`cat $SEATA_HOME/bin/seata.pid`
    kill -9 $pid
    echo "seata is stopped"
    ;;
  restart)
    pid=`cat $SEATA_HOME/bin/seata.pid`
    kill -9 $pid
    echo "seata is stopped"
    sleep 1
    nohup sh $SEATA_HOME/bin/seata-server.sh -p 8091 -h 192.168.116.135 > seata.out 2>&1 &
        echo $! > $SEATA_HOME/bin/seata.pid
    echo "seata is started"
    ;;
  *)
    echo "start|stop|restart"
    ;;
esac
exit 0
                    
  1. 给脚本添加权限chmod 755 seata
  2. 添加服务到开机项 chkconfig --add seata
  3. 设置为开机启动 chkconfig seata on
  4. 测试 service seata start
上一篇下一篇

猜你喜欢

热点阅读