Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
554278772d
!15 [sync] PR-13: set flags for BIND_NOW
From: @openeuler-sync-bot 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2023-02-09 11:37:03 +00:00
lyn1001
14f4eccb5f set flags for BIND_NOW
(cherry picked from commit 197fa75bf68a753386f0a2c598948408dbf7cfac)
2023-02-09 19:17:04 +08:00
openeuler-ci-bot
9556747ecf
!11 [sync] PR-10: 修复安选编译选项问题
From: @openeuler-sync-bot 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2023-02-09 04:36:27 +00:00
cherry530
351082dfa2 Set flags for build
Signed-off-by: cherry530 <xuping33@huawei.com>
(cherry picked from commit e104df79e00e3d214a8981d9bf51f46b5aba723d)
2023-02-09 11:47:20 +08:00
openeuler-ci-bot
ebce19f35f
!7 Add buildRequires systemd
From: @caodongxia 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2023-01-06 01:29:30 +00:00
caodongxia
7cb93f4dbc Add buildRequires systemd 2023-01-05 20:10:32 +08:00
openeuler-ci-bot
db1e234473 !6 [sync] PR-2: Log shutdown gracefully
From: @openeuler-sync-bot
Reviewed-by: @duguhaotian
Signed-off-by: @duguhaotian
2021-10-13 09:21:59 +00:00
chen-jan
1953059386 Log shutdown gracefully
(cherry picked from commit da020715f9fad2e7100ab9cc51dd433e56c2f1c6)
2021-10-11 11:32:41 +08:00
openeuler-ci-bot
aba3d449fb !1 pushgateway package init
From: @bzg1107
Reviewed-by: @jianminw
Signed-off-by: @jianminw
2021-07-31 12:04:20 +00:00
baizg1107
b9f517ce85 package init 2021-07-31 16:49:26 +08:00
7 changed files with 255 additions and 0 deletions

View File

@ -0,0 +1,85 @@
From 92c8d1e028bc6a102bb578e03ba19776bff379ed Mon Sep 17 00:00:00 2001
From: marie <marie.payne@hotmail.ca>
Date: Thu, 7 Oct 2021 06:10:11 -0400
Subject: [PATCH] Log shutdown gracefully (#428)
Log graceful shutdown at info level only
reference:
https://github.com/prometheus/pushgateway/commit/92c8d1e028bc6a102bb578e03ba19776bff379ed
Signed-off-by: mjip <marie.payne@hotmail.ca>
---
main.go | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/main.go b/main.go
index bdf61e8..2927d71 100644
--- a/main.go
+++ b/main.go
@@ -14,6 +14,7 @@
package main
import (
+ "context"
"fmt"
"net"
"net/http"
@@ -25,7 +26,6 @@ import (
"path/filepath"
"strings"
"syscall"
- "time"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
@@ -191,13 +191,20 @@ func main() {
mux.Handle(apiPath+"/v1/", http.StripPrefix(apiPath+"/v1", av1))
- go closeListenerOnQuit(l, quitCh, logger)
- err = (&http.Server{Addr: *listenAddress, Handler: mux}).Serve(l)
- level.Error(logger).Log("msg", "HTTP server stopped", "err", err)
- // To give running connections a chance to submit their payload, we wait
- // for 1sec, but we don't want to wait long (e.g. until all connections
- // are done) to not delay the shutdown.
- time.Sleep(time.Second)
+ server := &http.Server{
+ Addr: *listenAddress,
+ Handler: mux,
+ }
+ go shutdownServerOnQuit(server, quitCh, logger)
+ err = (server).Serve(l)
+
+ // In the case of a graceful shutdown, do not log the error.
+ if err == http.ErrServerClosed {
+ level.Info(logger).Log("msg", "HTTP server stopped")
+ } else {
+ level.Error(logger).Log("msg", "HTTP server stopped", "err", err)
+ }
+
if err := ms.Shutdown(); err != nil {
level.Error(logger).Log("msg", "problem shutting down metric storage", "err", err)
}
@@ -237,9 +244,9 @@ func computeRoutePrefix(prefix string, externalURL *url.URL) string {
return prefix
}
-// closeListenerOnQuite closes the provided listener upon closing the provided
+// shutdownServerOnQuit shutdowns the provided server upon closing the provided
// quitCh or upon receiving a SIGINT or SIGTERM.
-func closeListenerOnQuit(l net.Listener, quitCh <-chan struct{}, logger log.Logger) {
+func shutdownServerOnQuit(server *http.Server, quitCh <-chan struct{}, logger log.Logger) error {
notifier := make(chan os.Signal, 1)
signal.Notify(notifier, os.Interrupt, syscall.SIGTERM)
@@ -251,5 +258,5 @@ func closeListenerOnQuit(l net.Listener, quitCh <-chan struct{}, logger log.Logg
level.Warn(logger).Log("msg", "received termination request via web service, exiting gracefully...")
break
}
- l.Close()
+ return server.Shutdown(context.Background())
}
--
2.30.0

View File

@ -0,0 +1,65 @@
From f4984952bc9259a34b93b4bdf7581c1e586e7b36 Mon Sep 17 00:00:00 2001
From: bzg1107 <preloyalwhite@163.com>
Date: Sat, 31 Jul 2021 16:36:48 +0800
Subject: [PATCH] fix promu dependence and fix not found web
---
Makefile.common | 10 ++++++----
main.go | 5 +----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/Makefile.common b/Makefile.common
index ce80d53..d33966d 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -261,11 +261,13 @@ common-docker-manifest:
promu: $(PROMU)
$(PROMU):
- $(eval PROMU_TMP := $(shell mktemp -d))
- curl -s -L $(PROMU_URL) | tar -xvzf - -C $(PROMU_TMP)
+# $(eval PROMU_TMP := $(shell mktemp -d))
+# curl -s -L $(PROMU_URL) | tar -xvzf - -C $(PROMU_TMP)
+# mkdir -p $(FIRST_GOPATH)/bin
+# cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
+# rm -r $(PROMU_TMP)
mkdir -p $(FIRST_GOPATH)/bin
- cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
- rm -r $(PROMU_TMP)
+ cp /usr/bin/promu $(FIRST_GOPATH)/bin/promu
.PHONY: proto
proto:
diff --git a/main.go b/main.go
index 0c47d9d..bdf61e8 100644
--- a/main.go
+++ b/main.go
@@ -34,8 +34,6 @@ import (
"github.com/prometheus/common/promlog"
"github.com/prometheus/common/route"
"github.com/prometheus/common/version"
- "github.com/prometheus/exporter-toolkit/web"
- webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag"
"gopkg.in/alecthomas/kingpin.v2"
dto "github.com/prometheus/client_model/go"
@@ -61,7 +59,6 @@ func (lf logFunc) Println(v ...interface{}) {
func main() {
var (
app = kingpin.New(filepath.Base(os.Args[0]), "The Pushgateway")
- webConfig = webflag.AddFlags(app)
listenAddress = app.Flag("web.listen-address", "Address to listen on for the web interface, API, and telemetry.").Default(":9091").String()
metricsPath = app.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
externalURL = app.Flag("web.external-url", "The URL under which the Pushgateway is externally reachable.").Default("").URL()
@@ -195,7 +192,7 @@ func main() {
mux.Handle(apiPath+"/v1/", http.StripPrefix(apiPath+"/v1", av1))
go closeListenerOnQuit(l, quitCh, logger)
- err = web.Serve(l, &http.Server{Addr: *listenAddress, Handler: mux}, *webConfig, logger)
+ err = (&http.Server{Addr: *listenAddress, Handler: mux}).Serve(l)
level.Error(logger).Log("msg", "HTTP server stopped", "err", err)
// To give running connections a chance to submit their payload, we wait
// for 1sec, but we don't want to wait long (e.g. until all connections
--
2.30.0

BIN
pushgateway-1.4.1.tar.gz Normal file

Binary file not shown.

1
pushgateway.default Normal file
View File

@ -0,0 +1 @@
PUSHGATEWAY_OPTS='--web.listen-address=0.0.0.0:9091'

18
pushgateway.service Normal file
View File

@ -0,0 +1,18 @@
# -*- mode: conf -*-
[Unit]
Description=Prometheus pushgateway.
Documentation=https://github.com/prometheus/pushgateway
After=network.target
[Service]
EnvironmentFile=-/etc/default/pushgateway
User=prometheus
ExecStart=/usr/bin/pushgateway \
$PUSHGATEWAY_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target

86
pushgateway.spec Normal file
View File

@ -0,0 +1,86 @@
%define debug_package %{nil}
%ifarch aarch64
%global hostarch arm64
%endif
%ifarch x86_64
%global hostarch amd64
%endif
Name: pushgateway
Version: 1.4.1
Release: 5
Summary: Prometheus pushgateway.
License: ASL 2.0
URL: https://github.com/prometheus/%{name}
Source0: https://github.com/prometheus/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: %{name}.service
Source2: %{name}.default
Source3: vendor.tar.gz
Patch0: 0001-fix-promu-dependence-and-fix-not-found-web.patch
Patch1: 0001-Log-shutdown-gracefully-428.patch
BuildRequires: golang >= 1.13
BuildRequires: promu
BuildRequires: systemd
%{?systemd_requires}
Requires(pre): shadow-utils
%description
The Prometheus Pushgateway exists to allow ephemeral and batch jobs to expose their metrics to Prometheus.
Since these kinds of jobs may not exist long enough to be scraped, they can instead push their metrics to a Pushgateway.
The Pushgateway then exposes these metrics to Prometheus.
%prep
%autosetup -p1 -n %{name}-%{version}
%setup -T -D -a 3 -n %{name}-%{version}
%build
mkdir -p $(pwd)/bin
export GOBIN=$(pwd)/bin
go build -mod=vendor -buildmode=pie -ldflags "-s -w -linkmode=external -extldflags '-Wl,-z,relro -Wl,-z,now' " -o bin ./ ...
%install
mkdir -p %{buildroot}%{_bindir}
install -D -m 755 bin/%{name} %{buildroot}%{_bindir}/
mkdir -vp %{buildroot}%{_sharedstatedir}/prometheus
install -D -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
install -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/default/%{name}
%pre
getent group prometheus >/dev/null || groupadd -r prometheus
getent passwd prometheus >/dev/null || \
useradd -r -g prometheus -d %{_sharedstatedir}/prometheus -s /sbin/nologin \
-c "Prometheus services" prometheus
exit 0
%post
%systemd_post %{name}.service
%preun
%systemd_preun %{name}.service
%postun
%systemd_postun %{name}.service
%files
%defattr(-,root,root,-)
%{_bindir}/*
%{_unitdir}/%{name}.service
%config(noreplace) %{_sysconfdir}/default/%{name}
%dir %attr(755, prometheus, prometheus)%{_sharedstatedir}/prometheus
%changelog
* Thu Feb 09 2023 xu_ping <xuping33@h-partners.com> - 1.4.1-5
- set flags for BIND_NOW
* Thu Feb 09 2023 xu_ping <xuping33@h-partners.com> - 1.4.1-4
- set flags for build
* Thu Jan 5 2023 caodongxia <caodongxia@h-partners.com> - 1.4.1-3
- Add buildRequires systemd
* Mon Oct 11 2021 chenchen <chen_aka_jan@163.com> - 1.4.1-2
- Logr shutdownr gracefully(#428
* Wed Jul 14 2021 baizhonggui <baizhonggui@huawei.com> - 1.4.1-1
- Package init

BIN
vendor.tar.gz Normal file

Binary file not shown.