Linux Haproxy startup script sharing

Source: Internet
Author: User
Tags haproxy

#!/bin/bash

#created by Teddylu on 2014-1-15

#used for haproxy-1.4.26

Base= "/application/haproxy"

prog= $BASE/sbin/haproxy

pidfile= $BASE/var/run/haproxy.pid

conffile= $BASE/conf/haproxy.conf



Case "$" in

Start

# $PROG-F $CONFFILE >/dev/null 2>&1

$PROG-F $CONFFILE

;;

Status

if [!-f $PIDFILE]; Then

echo "pid not Found"

Exit 1

Fi

For PID in $ (cat $PIDFILE); Todo

kill-0 $pid

Retval= "$?"

if [! "$RETVAL" = "0"]; Then

echo "Process $pid died"

Exit 1

Fi

Done

echo "Process is running"

;;

Restart)

$PROG-F $CONFFILE-sf $ (cat $PIDFILE) >/dev/null 2>&1

;;

Stop

Kill $ (Cat $PIDFILE)

;;

*)

echo "USAGE: $ start|restart|status|stop"

Exit 1

;;

Esac


#启动haproxy

/application/haproxy/bin/haproxy start

[Root@haproxy_01 teddylu]# Netstat-lntp|grep Haproxy

TCP 0 0 192.168.1.104:80 0.0.0.0:* LISTEN 6035/haproxy

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.