diff --git a/fabio/fabio.properties b/fabio/fabio.properties new file mode 100644 index 0000000000..0ce5839799 --- /dev/null +++ b/fabio/fabio.properties @@ -0,0 +1,37 @@ +## +## fabio.properties -- Fabio Server Configuration +## + +proxy.addr = \ + 127.0.0.1:8080, \ + 127.0.0.1:8443;@l_prefix@/etc/x509/example-server.crt.pem;@l_prefix@/etc/x509/example-server.key.pem + +proxy.strategy = rnd +proxy.matcher = prefix +proxy.noroutestatus = 404 +proxy.shutdownwait = 0s +proxy.timeout = 0s +proxy.dialtimeout = 30s +proxy.maxconn = 10000 + +registry.backend = consul +registry.consul.addr = 127.0.0.1:8500 +registry.consul.token = +registry.consul.kvpath = /fabio/config +registry.consul.tagprefix = urlprefix- +registry.consul.register.enabled = true +registry.consul.register.addr = 127.0.0.1:9998 +registry.consul.register.name = fabio +registry.consul.register.tags = +registry.consul.register.checkInterval = 1s +registry.consul.register.checkTimeout = 3s + +metrics.target = + +runtime.gogc = 800 +runtime.gomaxprocs = -1 + +ui.addr = 127.0.0.1:9998 +ui.color = light-green +ui.title = + diff --git a/fabio/fabio.spec b/fabio/fabio.spec new file mode 100644 index 0000000000..4e005f7d37 --- /dev/null +++ b/fabio/fabio.spec @@ -0,0 +1,126 @@ +## +## fabio.spec -- OpenPKG RPM Package Specification +## Copyright (c) 2000-2016 OpenPKG Foundation e.V. +## +## Permission to use, copy, modify, and distribute this software for +## any purpose with or without fee is hereby granted, provided that +## the above copyright notice and this permission notice appear in all +## copies. +## +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +## SUCH DAMAGE. +## + +# package version +%define V_fabio 1.1.3 +%define V_fabio_base 1.1.3 +%define V_fabio_snap 20160611 + +# package information +Name: fabio +Summary: Reverse Proxy Based on Consul +URL: https://github.com/eBay/fabio +Vendor: eBay Software Foundation +Packager: OpenPKG Foundation e.V. +Distribution: OpenPKG Community +Class: EVAL +Group: Network +License: MIT +Version: %{V_fabio} +Release: 20160611 + +# list of sources +Source0: http://download.openpkg.org/components/versioned/fabio/fabio-%{V_fabio_snap}.tar.xz +Source1: rc.fabio +Source2: fabio.properties + +# build information +BuildPreReq: OpenPKG, openpkg >= 20160101, go, go-bindata +PreReq: OpenPKG, openpkg >= 20160101 + +%description + Traefik is a reverse proxy for HTTP API management and + microservices. It uses Etcd or Consul as a configuration backend, so + changes to configuration take effect immediately without restarting + the service. + +%track + prog fabio:release = { + version = %{V_fabio_base} + url = https://github.com/eBay/fabio/releases + regex = v(\d+\.\d+\.\d+-beta\.\d+)\.tar\.gz + } + prog fabio:snapshot = { + version = %{V_fabio_snap} + url = http://download.openpkg.org/components/versioned/fabio/ + regex = fabio-(__VER__)\.tar\.xz + } + +%prep + %setup -q -n fabio + +%build + # build program + export GOPATH=`pwd` + cd src/github.com/eBay/fabio + go build -x -o fabio . + +%install + # create directory hierarchy + %{l_shtool} mkdir -f -p -m 755 \ + $RPM_BUILD_ROOT%{l_prefix}/sbin \ + $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ + $RPM_BUILD_ROOT%{l_prefix}/etc/fabio \ + $RPM_BUILD_ROOT%{l_prefix}/var/fabio/run \ + $RPM_BUILD_ROOT%{l_prefix}/var/fabio/log + + # install program + %{l_shtool} install -c -s -m 755 \ + src/github.com/eBay/fabio/fabio \ + $RPM_BUILD_ROOT%{l_prefix}/sbin/ + + # install run-command script + %{l_shtool} install -c -m 755 %{l_value -s -a} \ + %{SOURCE rc.fabio} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ + + # install default configuration + %{l_shtool} install -c -m 644 %{l_value -s -a} \ + %{SOURCE fabio.properties} $RPM_BUILD_ROOT%{l_prefix}/etc/fabio/ + + # determine installation files + %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ + %{l_files_std} \ + '%config %{l_prefix}/etc/fabio/*' \ + '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/fabio/*' + +%files -f files + +%clean + +%post + if [ $1 -eq 2 ]; then + # after upgrade, restart service + eval `%{l_rc} fabio status 2>/dev/null` + [ ".$fabio_active" = .yes ] && %{l_rc} fabio restart + fi + exit 0 + +%preun + # before erase, stop service and remove log files + if [ $1 -eq 0 ]; then + %{l_rc} fabio stop 2>/dev/null + rm -f $RPM_INSTALL_PREFIX/var/fabio/log/* >/dev/null 2>&1 || true + rm -f $RPM_INSTALL_PREFIX/var/fabio/run/* >/dev/null 2>&1 || true + fi + exit 0 + diff --git a/fabio/rc.fabio b/fabio/rc.fabio new file mode 100644 index 0000000000..5e7b98e51c --- /dev/null +++ b/fabio/rc.fabio @@ -0,0 +1,62 @@ +#!@l_prefix@/bin/openpkg rc +## +## rc.fabio -- Run-Commands +## + +%config + fabio_enable="$openpkg_rc_def" + fabio_flags="" + fabio_log_prolog="true" + fabio_log_epilog="true" + fabio_log_numfiles="10" + fabio_log_minsize="1M" + fabio_log_complevel="9" + +%common + fabio_cfgfile="@l_prefix@/etc/fabio/fabio.properties" + fabio_pidfile="@l_prefix@/var/fabio/run/fabio.pid" + fabio_logfile="@l_prefix@/var/fabio/log/fabio.log" + fabio_signal () { + [ -f $fabio_pidfile ] && kill -$1 `cat $fabio_pidfile` + } + +%status -u @l_susr@ -o + fabio_usable="unknown" + fabio_active="no" + rcService fabio enable yes && \ + fabio_signal 0 && fabio_active="yes" + echo "fabio_enable=\"$fabio_enable\"" + echo "fabio_usable=\"$fabio_usable\"" + echo "fabio_active=\"$fabio_active\"" + +%start -u @l_susr@ + rcService fabio enable yes || exit 0 + rcService fabio active yes && exit 0 + ( nohup @l_prefix@/sbin/fabio \ + -cfg "$fabio_cfgfile" \ + $fabio_flags \ + >$fabio_logfile 2>&1 & + echo $! >$fabio_pidfile + ) >/dev/null 2>&1 + +%stop -u @l_susr@ + rcService fabio enable yes || exit 0 + rcService fabio active no && exit 0 + fabio_signal TERM + sleep 2 + rm -f $fabio_pidfile >/dev/null 2>&1 || true + +%restart -u @l_susr@ + rcService fabio enable yes || exit 0 + rcService fabio active no && exit 0 + rc fabio stop start + +%daily -u @l_susr@ + rcService fabio enable yes || exit 0 + shtool rotate -f \ + -n ${fabio_log_numfiles} -s ${fabio_log_minsize} -d \ + -z ${fabio_log_complevel} -m 664 -o @l_susr@ -g @l_sgrp@ \ + -P "${fabio_log_prolog}" \ + -E "${fabio_log_epilog}; rc fabio restart" \ + $fabio_logfile +