foreman_maintain 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_maintain/concerns/system_helpers.rb +3 -0
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +2 -7
- data/bin/passenger-recycler +0 -89
- data/config/passenger-recycler.yaml +0 -38
- data/definitions/procedures/passenger_recycler.rb +0 -14
- data/extras/passenger-recycler.cron +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5223427d91fd37a6dda0c341fada111c6555378cca050db661e81e4807bac53
|
4
|
+
data.tar.gz: 0ccf33ffe89749016e9b943b9421427f456e524fcd8a1d2f44a0aa3a02c7af8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe155208da6aa978763d158e89f6552897a4d26e7aae09af6182c5d055988348176693050a5197f07203366083902bda7a76cb2d569298e52f7aa70723dc9ee0
|
7
|
+
data.tar.gz: c323b7a0c47767f86cfbc58b1d3257d0ce005f80ae9d73cdb908e98796db28e9d1044348bd78b35baef8bef714fbc8a59cc6925222db60bb80fe3b505594bb20
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -113,7 +113,6 @@ description: Provides various features that helps keeping the Foreman/Satellite
|
|
113
113
|
email: inecas@redhat.com
|
114
114
|
executables:
|
115
115
|
- foreman-maintain
|
116
|
-
- passenger-recycler
|
117
116
|
- foreman-maintain-complete
|
118
117
|
- foreman-maintain-rotate-tar
|
119
118
|
extensions: []
|
@@ -126,12 +125,10 @@ files:
|
|
126
125
|
- bin/foreman-maintain
|
127
126
|
- bin/foreman-maintain-complete
|
128
127
|
- bin/foreman-maintain-rotate-tar
|
129
|
-
- bin/passenger-recycler
|
130
128
|
- config/foreman-maintain.completion
|
131
129
|
- config/foreman_maintain.yml.example
|
132
130
|
- config/foreman_maintain.yml.packaging
|
133
131
|
- config/hammer.yml.example
|
134
|
-
- config/passenger-recycler.yaml
|
135
132
|
- definitions/checks/backup/certs_tar_exist.rb
|
136
133
|
- definitions/checks/backup/directory_ready.rb
|
137
134
|
- definitions/checks/candlepin/db_up.rb
|
@@ -281,7 +278,6 @@ files:
|
|
281
278
|
- definitions/procedures/packages/unlock_versions.rb
|
282
279
|
- definitions/procedures/packages/update.rb
|
283
280
|
- definitions/procedures/packages/update_all_confirmation.rb
|
284
|
-
- definitions/procedures/passenger_recycler.rb
|
285
281
|
- definitions/procedures/prep_6_10_upgrade.rb
|
286
282
|
- definitions/procedures/pulp/cleanup_old_metadata_files.rb
|
287
283
|
- definitions/procedures/pulp/migrate.rb
|
@@ -365,7 +361,6 @@ files:
|
|
365
361
|
- extras/foreman_protector/foreman-protector.conf
|
366
362
|
- extras/foreman_protector/foreman-protector.whitelist
|
367
363
|
- extras/foreman_protector/yum/foreman-protector.py
|
368
|
-
- extras/passenger-recycler.cron
|
369
364
|
- lib/foreman_maintain.rb
|
370
365
|
- lib/foreman_maintain/check.rb
|
371
366
|
- lib/foreman_maintain/cli.rb
|
data/bin/passenger-recycler
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Trivial Passenger memory monitor and recycler. See the configuration file
|
4
|
-
# /etc/passenger-recycler.yaml for options. Execute via SCL.
|
5
|
-
#
|
6
|
-
require 'yaml'
|
7
|
-
|
8
|
-
CONFIG = {}.freeze
|
9
|
-
CONFIG_FILE = '/etc/passenger-recycler.yaml'.freeze
|
10
|
-
CONFIG = YAML.load_file(CONFIG_FILE) if File.readable?(CONFIG_FILE)
|
11
|
-
exit 0 unless CONFIG[:ENABLED]
|
12
|
-
|
13
|
-
def running?(pid)
|
14
|
-
Process.getpgid(pid) != -1
|
15
|
-
rescue Errno::ESRCH
|
16
|
-
false
|
17
|
-
end
|
18
|
-
|
19
|
-
def debug(msg)
|
20
|
-
puts(msg) if CONFIG[:DEBUG]
|
21
|
-
end
|
22
|
-
|
23
|
-
def verbose(msg)
|
24
|
-
puts(msg) if CONFIG[:VERBOSE]
|
25
|
-
end
|
26
|
-
|
27
|
-
def kill(pid)
|
28
|
-
return unless running?(pid) && CONFIG[:KILL_BUSY]
|
29
|
-
verbose "Process #{pid} is still running, sending SIGKILL"
|
30
|
-
Process.kill 'KILL', pid
|
31
|
-
sleep 5
|
32
|
-
end
|
33
|
-
|
34
|
-
def process_status?(pid)
|
35
|
-
if running?(pid)
|
36
|
-
verbose "Process #{pid} still terminating, moving on..."
|
37
|
-
else
|
38
|
-
verbose "Process successfully #{pid} terminated"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def show_passenger_status(status_messages)
|
43
|
-
status_messages.each { |msg| verbose msg }
|
44
|
-
end
|
45
|
-
|
46
|
-
require 'phusion_passenger'
|
47
|
-
PhusionPassenger.locate_directories
|
48
|
-
require 'phusion_passenger/platform_info'
|
49
|
-
require 'phusion_passenger/platform_info/ruby'
|
50
|
-
require 'phusion_passenger/admin_tools/memory_stats'
|
51
|
-
stats = PhusionPassenger::AdminTools::MemoryStats.new
|
52
|
-
killed = 0
|
53
|
-
|
54
|
-
def get_process_start(pid)
|
55
|
-
`ps -p#{pid} -o start=`.strip
|
56
|
-
rescue StandardError => e
|
57
|
-
verbose "Error: #{e.message} \nReturning '?'"
|
58
|
-
'?'
|
59
|
-
end
|
60
|
-
|
61
|
-
def get_rss_info(process)
|
62
|
-
get_pid_mem_kb = process.private_dirty_rss || process.rss
|
63
|
-
get_pid_mem_mb = format('%.0f', get_pid_mem_kb / 1024)
|
64
|
-
[get_pid_mem_kb, get_pid_mem_mb]
|
65
|
-
end
|
66
|
-
|
67
|
-
stats.passenger_processes.each do |p|
|
68
|
-
pid = p.pid.to_i
|
69
|
-
started = get_process_start(pid)
|
70
|
-
get_pid_mem_kb, get_pid_mem_mb = get_rss_info(p)
|
71
|
-
debug "Checking #{pid} with RSS of #{get_pid_mem_kb}"
|
72
|
-
next unless get_pid_mem_kb > CONFIG[:MAX_PRIV_RSS_MEMORY]
|
73
|
-
status_ps = `ps -p#{pid} -u`
|
74
|
-
status_all = `passenger-status 2> /dev/null`
|
75
|
-
status_backtraces = `passenger-status --show=backtraces 2>/dev/null`
|
76
|
-
verbose("Terminating #{pid} (started #{started}) with private RSS size of #{get_pid_mem_mb} MB")
|
77
|
-
begin
|
78
|
-
Process.kill 'SIGUSR1', pid
|
79
|
-
sleep CONFIG[:GRACEFUL_SHUTDOWN_SLEEP]
|
80
|
-
kill(pid)
|
81
|
-
process_status?(pid)
|
82
|
-
show_passenger_status([status_ps, status_all, status_backtraces]) if CONFIG[:SEND_STATUS]
|
83
|
-
killed += 1
|
84
|
-
exit(1) if killed >= CONFIG[:MAX_TERMINATION]
|
85
|
-
rescue Errno::ESRCH
|
86
|
-
puts "#{Process.pid}: #{pid} is NOT running"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
exit 0
|
@@ -1,38 +0,0 @@
|
|
1
|
-
---
|
2
|
-
#
|
3
|
-
# Trivial Passenger memory monitor. By default it is executed from cron every
|
4
|
-
# five minutes and it kills processes exceeding the RSS memory threashold
|
5
|
-
# configured with MAX_PRIV_RSS_MEMORY. Up to MAX_TERMINATION processes is
|
6
|
-
# terminated during one execution.
|
7
|
-
#
|
8
|
-
|
9
|
-
# Set to 'false' to completely disable this script.
|
10
|
-
:ENABLED: true
|
11
|
-
|
12
|
-
# RSS memory threashold to recycle processes (in kB).
|
13
|
-
:MAX_PRIV_RSS_MEMORY: 2_000_000
|
14
|
-
|
15
|
-
# Controls amount of processes killed during one run. This number should be
|
16
|
-
# smaller by one or two than maximum allowed amount of processes by passenger
|
17
|
-
# (defaults to 6) so there is at least one process left.
|
18
|
-
:MAX_TERMINATION: 1
|
19
|
-
|
20
|
-
# Kill processes which do not terminate gracefully using SIGKILL after
|
21
|
-
# GRACEFUL_SHUTDOWN_SLEEP period.
|
22
|
-
:KILL_BUSY: true
|
23
|
-
|
24
|
-
# Amount of seconds to wait for graceful shutdown (SIGTERM) until a process
|
25
|
-
# kill (SIGKILL) is sent. Must be lower than 15 minutes (900 seconds). This
|
26
|
-
# gives Passenger some extra time for respawning application before another
|
27
|
-
# process is terminated.
|
28
|
-
:GRACEFUL_SHUTDOWN_SLEEP: 90
|
29
|
-
|
30
|
-
# Print 'passenger-status' and 'ps' output before termination to get some extra
|
31
|
-
# information via email from cron. Only printed when a kill is performed.
|
32
|
-
:SEND_STATUS: true
|
33
|
-
|
34
|
-
# Print verbose information "Process terminating" or "Process killed".
|
35
|
-
:VERBOSE: true
|
36
|
-
|
37
|
-
# Print extra debugging information.
|
38
|
-
:DEBUG: false
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Procedures::PassengerRecycler < ForemanMaintain::Procedure
|
2
|
-
metadata do
|
3
|
-
description 'Perform Passenger memory recycling'
|
4
|
-
|
5
|
-
confine do
|
6
|
-
execute?('which passenger-recycler')
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
passenger_recycler_path = execute('which passenger-recycler')
|
12
|
-
execute!(passenger_recycler_path)
|
13
|
-
end
|
14
|
-
end
|