forked from ahmadrezamontazerolghaem/Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTLWL.cc
169 lines (142 loc) · 5.16 KB
/
TLWL.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
%define haproxy_user haproxy
%define haproxy_group %{haproxy_user}
%define haproxy_home %{_localstatedir}/lib/haproxy
%if 0%{?rhel} == 7
# CentOS 7 forces ".el7.centos", wtf CentOS maintainers...
%define dist .el7
%endif
%if 0%{?rhel} < 7
%{!?__global_ldflags: %global __global_ldflags -Wl,-z,relro}
%endif
Summary: HA-Proxy is a TCP/HTTP reverse proxy for high availability environments
Name: haproxy
Version: %{version}
Release: %{release}%{?dist}
License: GPL
Group: System Environment/Daemons
URL: http://www.haproxy.org/
Source0: http://www.haproxy.org/download/1.6/src/%{name}-%{version}.tar.gz
Source1: %{name}.cfg
%{?el6:Source2: %{name}.init}
%{?el7:Source2: %{name}.service}
Source3: %{name}.logrotate
Source4: %{name}.syslog%{?dist}
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: pcre-devel make gcc openssl-devel
Requires(pre): shadow-utils
%if 0%{?el6}
Requires(post): chkconfig, initscripts
Requires(preun): chkconfig, initscripts
Requires(postun): initscripts
%endif
%if 0%{?el7}
BuildRequires: systemd-units
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif
%description
HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high
availability environments. Indeed, it can:
- route HTTP requests depending on statically assigned cookies
- spread the load among several servers while assuring server persistence
through the use of HTTP cookies
- switch to backup servers in the event a main one fails
- accept connections to special ports dedicated to service monitoring
- stop accepting connections without breaking existing ones
- add/modify/delete HTTP headers both ways
- block requests matching a particular pattern
It needs very little resource. Its event-driven architecture allows it to easily
handle thousands of simultaneous connections on hundreds of instances without
risking the system's stability.
%prep
%setup -q
# We don't want any perl dependecies in this RPM:
%define __perl_requires /bin/true
%build
regparm_opts=
%ifarch %ix86 x86_64
regparm_opts="USE_REGPARM=1"
%endif
%{__make} %{?_smp_mflags} CPU="generic" TARGET="linux2628" USE_OPENSSL=1 USE_PCRE=1 USE_ZLIB=1 ${regparm_opts} ADDINC="%{optflags}" USE_LINUX_TPROXY=1 ADDLIB="%{__global_ldflags}" DEFINE=-DTCP_USER_TIMEOUT=18
%install
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%{__install} -d %{buildroot}%{_sbindir}
%{__install} -d %{buildroot}%{_sysconfdir}/logrotate.d
%{__install} -d %{buildroot}%{_sysconfdir}/rsyslog.d
%{__install} -d %{buildroot}%{_sysconfdir}/%{name}
%{__install} -d %{buildroot}%{_sysconfdir}/%{name}/errors
%{__install} -d %{buildroot}%{_localstatedir}/log/%{name}
%{__install} -d %{buildroot}%{_mandir}/man1/
%{__install} -s %{name} %{buildroot}%{_sbindir}/
%if 0%{?el6}
%{__install} -d %{buildroot}%{_sysconfdir}/rc.d/init.d
%{__install} -c -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name}
%endif
%if 0%{?el7}
%{__install} -s %{name}-systemd-wrapper %{buildroot}%{_sbindir}/
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service
%endif
%{__install} -c -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/%{name}/
%{__install} -c -m 755 examples/errorfiles/*.http %{buildroot}%{_sysconfdir}/%{name}/errors/
%{__install} -c -m 755 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
%{__install} -c -m 755 %{SOURCE4} %{buildroot}%{_sysconfdir}/rsyslog.d/49-%{name}.conf
%{__install} -c -m 755 doc/%{name}.1 %{buildroot}%{_mandir}/man1/
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%pre
getent group %{haproxy_group} >/dev/null || \
groupadd -g 188 -r %{haproxy_group}
getent passwd %{haproxy_user} >/dev/null || \
useradd -u 188 -r -g %{haproxy_group} -d %{haproxy_home} \
-s /sbin/nologin -c "%{name}" %{haproxy_user}
exit 0
%post
%if 0%{?el7}
%systemd_post %{name}.service
systemctl restart rsyslog.service
%endif
%if 0%{?el6}
/sbin/chkconfig --add %{name}
/sbin/service rsyslog restart >/dev/null 2>&1 || :
%endif
%preun
%if 0%{?el7}
%systemd_preun %{name}.service
%endif
%if 0%{?el6}
if [ $1 = 0 ]; then
/sbin/service %{name} stop >/dev/null 2>&1 || :
/sbin/chkconfig --del %{name}
fi
%endif
%postun
%if 0%{?el7}
%systemd_postun_with_restart %{name}.service
systemctl restart rsyslog.service
%endif
%if 0%{?el6}
if [ "$1" -ge "1" ]; then
/sbin/service %{name} condrestart >/dev/null 2>&1 || :
/sbin/service rsyslog restart >/dev/null 2>&1 || :
fi
%endif
%files
%defattr(-,root,root)
%doc CHANGELOG README examples/*.cfg doc/architecture.txt doc/configuration.txt doc/intro.txt doc/management.txt doc/proxy-protocol.txt
%doc %{_mandir}/man1/%{name}.1*
%dir %{_localstatedir}/log/%{name}
%attr(0755,root,root) %{_sbindir}/%{name}
%if 0%{?el6}
%attr(0755,root,root) %config %_sysconfdir/rc.d/init.d/%{name}
%endif
%if 0%{?el7}
%attr(0755,root,root) %{_sbindir}/%{name}-systemd-wrapper
%attr(-,root,root) %{_unitdir}/%{name}.service
%endif
%dir %{_sysconfdir}/%{name}
%{_sysconfdir}/%{name}/errors
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.cfg
%attr(0644,root,root) %config %{_sysconfdir}/logrotate.d/%{name}
%attr(0644,root,root) %config %{_sysconfdir}/rsyslog.d/49-%{name}.conf
%changelo