Skip to content

Commit ba1c807

Browse files
Add some logging when restart is accepted and when a duplicate restart is ignored
Apply suggestion from @corporate-gadfly Co-authored-by: Corporate Gadfly <corporate-gadfly@users.noreply.github.com> Signed-off-by: Tim Meusel <tim@bastelfreak.de>
1 parent e548da1 commit ba1c807

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
[org.openvoxproject/i18n ~i18n-version]]
9696

9797
:eastwood {:ignored-faults {:reflection {puppetlabs.trapperkeeper.logging [{:line 92}]
98-
puppetlabs.trapperkeeper.internal [{:line 220}]
98+
puppetlabs.trapperkeeper.internal [{:line 230}]
9999
puppetlabs.trapperkeeper.testutils.logging true
100100
puppetlabs.trapperkeeper.testutils.logging-test true
101101
puppetlabs.trapperkeeper.services.nrepl.nrepl-service-test true

src/puppetlabs/trapperkeeper/internal.clj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,25 @@
113113
(defn should-handle-sighup-restart?
114114
[]
115115
(let [current-ms (now-ms)
116-
accepted? (atom false)]
116+
accepted? (atom false)
117+
previous-ms (atom nil)]
117118
(swap! last-sighup-restart-ms
118119
(fn [last-ms]
120+
(reset! previous-ms last-ms)
119121
(if (and (some? last-ms)
120122
(< (- current-ms last-ms) min-sighup-restart-interval-ms))
121123
last-ms
122124
(do
123125
(reset! accepted? true)
124126
current-ms))))
127+
(if @accepted?
128+
(log/debug (i18n/trs "Accepting SIGHUP restart at {0}; previous accepted restart was {1}"
129+
current-ms
130+
@previous-ms))
131+
(log/warn (i18n/trs "Ignoring duplicate SIGHUP restart at {0}; previous accepted restart was {1}; minimum interval is {2} ms"
132+
current-ms
133+
@previous-ms
134+
min-sighup-restart-interval-ms)))
125135
@accepted?))
126136

127137
(defn app-log-id

0 commit comments

Comments
 (0)