Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
922cbc9606
!19 add loong64 support
From: @zhangxianting 
Reviewed-by: @yangzhao_kl 
Signed-off-by: @yangzhao_kl
2024-10-29 13:29:48 +00:00
zhangxianting
61b489b06b add loong64 support 2024-07-02 15:50:55 +08:00
openeuler-ci-bot
24a943df54
!13 set flags for BIND_NOW
From: @lyn1001 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2023-02-09 11:16:56 +00:00
lyn1001
197fa75bf6 set flags for BIND_NOW 2023-02-09 17:46:56 +08:00
openeuler-ci-bot
379d083285
!12 [sync] PR-10: 修复安选编译选项问题
From: @openeuler-sync-bot 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2023-02-09 04:36:45 +00:00
cherry530
3107647488 Set flags for build
Signed-off-by: cherry530 <xuping33@huawei.com>
(cherry picked from commit e104df79e00e3d214a8981d9bf51f46b5aba723d)
2023-02-09 11:47:27 +08:00
openeuler-ci-bot
a7863c1365
!8 [sync] PR-7: Add buildRequires systemd
From: @openeuler-sync-bot 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
2023-01-13 07:54:00 +00:00
caodongxia
34462c60de Add buildRequires systemd
(cherry picked from commit 7cb93f4dbc38117dea8447a644d4253c7d51ca2a)
2023-01-13 15:45:10 +08:00
openeuler-ci-bot
9d73720dcf !3 [sync] PR-2: Log shutdown gracefully
From: @openeuler-sync-bot
Reviewed-by: @duguhaotian
Signed-off-by: @duguhaotian
2021-10-11 06:24:46 +00:00
chen-jan
219e6241ad Log shutdown gracefully
(cherry picked from commit da020715f9fad2e7100ab9cc51dd433e56c2f1c6)
2021-10-11 11:32:34 +08:00
3 changed files with 2742 additions and 3 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

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
Name: pushgateway Name: pushgateway
Version: 1.4.1 Version: 1.4.1
Release: 1 Release: 6
Summary: Prometheus pushgateway. Summary: Prometheus pushgateway.
License: ASL 2.0 License: ASL 2.0
URL: https://github.com/prometheus/%{name} URL: https://github.com/prometheus/%{name}
@ -17,9 +17,12 @@ Source1: %{name}.service
Source2: %{name}.default Source2: %{name}.default
Source3: vendor.tar.gz Source3: vendor.tar.gz
Patch0: 0001-fix-promu-dependence-and-fix-not-found-web.patch Patch0: 0001-fix-promu-dependence-and-fix-not-found-web.patch
Patch1: 0001-Log-shutdown-gracefully-428.patch
Patch2: 0001-add-loong64-support.patch
BuildRequires: golang >= 1.13 BuildRequires: golang >= 1.13
BuildRequires: promu BuildRequires: promu
BuildRequires: systemd
%{?systemd_requires} %{?systemd_requires}
Requires(pre): shadow-utils Requires(pre): shadow-utils
@ -29,13 +32,16 @@ Since these kinds of jobs may not exist long enough to be scraped, they can inst
The Pushgateway then exposes these metrics to Prometheus. The Pushgateway then exposes these metrics to Prometheus.
%prep %prep
%autosetup -p1 -n %{name}-%{version} %setup -n %{name}-%{version}
%setup -T -D -a 3 -n %{name}-%{version} %setup -T -D -a 3 -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build %build
mkdir -p $(pwd)/bin mkdir -p $(pwd)/bin
export GOBIN=$(pwd)/bin export GOBIN=$(pwd)/bin
go build -mod=vendor -o bin ./ ... go build -mod=vendor -buildmode=pie -ldflags "-s -w -linkmode=external -extldflags '-Wl,-z,relro -Wl,-z,now' " -o bin ./ ...
%install %install
mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_bindir}
@ -68,5 +74,20 @@ exit 0
%dir %attr(755, prometheus, prometheus)%{_sharedstatedir}/prometheus %dir %attr(755, prometheus, prometheus)%{_sharedstatedir}/prometheus
%changelog %changelog
* Tue Jul 02 2024 zhangxianting <zhangxianting@uniontech.com> - 1.4.1-6
- add loong64 support
* 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 * Wed Jul 14 2021 baizhonggui <baizhonggui@huawei.com> - 1.4.1-1
- Package init - Package init