vi /etc/init.d/rabbitmq
#!/bin/bash
#
# chkconfig: 2345 80 05
# description: rabbitmq
# processname: rabbitmq
#RabbitMQ安裝目錄
RABBITMQ_HOME=/usr/local/rabbitmq_server-3.8.16
export RABBITMQ_HOME
case "$1" in
start)
echo "Starting RabbitMQ ..."
cd $RABBIT_HOME/sbin
rabbitmq-server
;;
stop)
echo "Stopping RabbitMQ ..."
cd $RABBIT_HOME/sbin
rabbitmqctl stop
;;
status)
echo "Status RabbitMQ ..."
cd $RABBIT_HOME/sbin
rabbitmqctl status
;;
restart)
echo "Restarting RabbitMQ ..."
cd $RABBIT_HOME/sbin
rabbitmq-server
;;
*)
echo "Usage: $prog {start|stop|status|restart}"
;;
esac
exit 0
chmod +x /etc/init.d/rabbitmq