Linux RABBITMQ Boot script operations tutorial

Source: Internet
Author: User
Tags rabbitmq

Log a RABBITMQ startup script, and modify some of the parameters to use.
Vi/etc/init.d/rabbitmq-server #脚本内容, see the diagram, you need to modify the parameters
chmod +x/etc/init.d/rabbitmq-server
Chkconfig--add Rabbitmq-server
Chkconfig Rabbitmq-server on

The following figure:

#!/bin/sh
#
# Rabbitmq-server RABBITMQ Broker
#
# Chkconfig:-80 05
# description:enable AMQP service provided by RABBITMQ
#
### BEGIN INIT INFO
# Provides:rabbitmq-server
# Required-start: $remote _fs $network
# required-stop: $remote _fs $network
# DESCRIPTION:RABBITMQ Broker
# short-description:enable AMQP service provided by RABBITMQ Broker
### End INIT INFO
# Source function library.
. /etc/init.d/functions
Export Home=/root
Path=/sbin:/usr/sbin:/bin:/usr/bin
Name=rabbitmq-server
Daemon=/usr/local/rabbitmq/sbin/${name}
Control=/usr/local/rabbitmq/sbin/rabbitmqctl
Desc=rabbitmq-server
User=root
rotate_suffix=
Init_log_dir=/usr/local/rabbitmq/var/log/rabbitmq
Pid_file=/var/run/rabbitmq.pid
start_prog= "Daemon"
lock_file=/var/lock/subsys/$NAME
Test-x $DAEMON | | Exit 0
Test-x $CONTROL | | Exit 0
Retval=0
Set-e
[-f/etc/default/${name}] &&. /etc/default/${name}
START_RABBITMQ () {
STATUS_RABBITMQ quiet
if [$RETVAL = 0]; Then
Echo RABBITMQ is currently running
Else
Retval=0
Set +e
rabbitmq_pid_file= $PID _file $START _prog $DAEMON \
> "${init_log_dir}/startup_log" \
2> "${init_log_dir}/startup_err" \
0<&-&
$CONTROL wait $PID _file >/dev/null 2>&1
Retval=$?
Set-e
Case "$RETVAL" in
0)
Echo SUCCESS
If [-N "$LOCK _file"]; Then
Touch $LOCK _file
Fi
;;
*)
Echo Failed-check ${init_log_dir}/startup_\{log, _err\}
Retval=1
;;
Esac
Fi
}
STOP_RABBITMQ () {
STATUS_RABBITMQ quiet
if [$RETVAL = 0]; Then
Set +e
$CONTROL stop ${pid_file} > ${init_log_dir}/shutdown_log 2> ${init_log_dir}/shutdown_err
Retval=$?
Set-e
if [$RETVAL = 0]; Then
If [-N "$LOCK _file"]; Then
Rm-f $LOCK _file
Fi
Else
Echo Failed-check ${init_log_dir}/shutdown_log, _err
Fi
Else
Echo RABBITMQ is not running
Retval=0
Fi
}
STATUS_RABBITMQ () {
Set +e
If ["$"!= "quiet"]; Then
$CONTROL Status 2>&1
Else
$CONTROL Status >/dev/null 2>&1
Fi
If [$?!= 0]; Then
Retval=3
Fi
Set-e
}
ROTATE_LOGS_RABBITMQ () {
Set +e
$CONTROL Rotate_logs ${rotate_suffix}
If [$?!= 0]; Then
Retval=1
Fi
Set-e
}
RESTART_RUNNING_RABBITMQ () {
STATUS_RABBITMQ quiet
if [$RETVAL = 0]; Then
Restart_rabbitmq
Else
Echo RABBITMQ is not runnning
Retval=0
Fi
}
RESTART_RABBITMQ () {
Stop_rabbitmq
Start_rabbitmq
}
Case "$" in
Start
Echo-n "Starting $DESC:"
Start_rabbitmq
echo "$NAME."
;;
Stop
Echo-n "Stopping $DESC:"
Stop_rabbitmq
echo "$NAME."
;;
Status
Status_rabbitmq
;;
Rotate-logs)
Echo-n "Rotating log files for $DESC:"
Rotate_logs_rabbitmq
;;
Force-reload|reload|restart)
Echo-n "Restarting $DESC:"
Restart_rabbitmq
echo "$NAME."
;;
Try-restart)
Echo-n "Restarting $DESC:"
Restart_running_rabbitmq
echo "$NAME."
;;
*)
echo "Usage: $ {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
Retval=1
;;
Esac
Exit $RETVAL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.