foreman_maintain 1.1.1 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/definitions/features/foreman_database.rb +7 -1
- data/definitions/features/installer.rb +3 -1
- data/definitions/features/nftables.rb +5 -3
- data/definitions/features/puppet_server.rb +0 -2
- data/definitions/procedures/backup/config_files.rb +25 -10
- data/definitions/procedures/backup/metadata.rb +11 -7
- data/definitions/procedures/backup/offline/foreman_db.rb +30 -9
- data/definitions/procedures/backup/online/safety_confirmation.rb +1 -1
- data/definitions/procedures/content/prepare.rb +1 -0
- data/definitions/procedures/content/switchover.rb +1 -0
- data/definitions/procedures/foreman/apipie_cache.rb +1 -1
- data/definitions/procedures/installer/run_for_6_11.rb +52 -0
- data/definitions/procedures/maintenance_mode/disable_maintenance_mode.rb +2 -1
- data/definitions/procedures/maintenance_mode/enable_maintenance_mode.rb +1 -30
- data/definitions/procedures/packages/update.rb +3 -1
- data/definitions/procedures/restore/extract_files.rb +4 -0
- data/definitions/procedures/selinux/set_file_security.rb +3 -0
- data/definitions/scenarios/backup.rb +10 -0
- data/definitions/scenarios/packages.rb +2 -2
- data/definitions/scenarios/puppet.rb +3 -0
- data/definitions/scenarios/self_upgrade.rb +14 -61
- data/definitions/scenarios/upgrade_to_capsule_6_12.rb +90 -0
- data/definitions/scenarios/upgrade_to_capsule_6_12_z.rb +90 -0
- data/definitions/scenarios/upgrade_to_satellite_6_11.rb +1 -1
- data/definitions/scenarios/upgrade_to_satellite_6_12.rb +92 -0
- data/definitions/scenarios/upgrade_to_satellite_6_12_z.rb +91 -0
- data/lib/foreman_maintain/cli/packages_command.rb +26 -7
- data/lib/foreman_maintain/cli/self_upgrade_command.rb +1 -7
- data/lib/foreman_maintain/concerns/base_database.rb +31 -3
- data/lib/foreman_maintain/concerns/downstream.rb +2 -3
- data/lib/foreman_maintain/concerns/firewall/maintenance_mode.rb +31 -0
- data/lib/foreman_maintain/concerns/firewall/nftables_maintenance_mode.rb +3 -3
- data/lib/foreman_maintain/concerns/metadata.rb +4 -0
- data/lib/foreman_maintain/concerns/os_facts.rb +26 -2
- data/lib/foreman_maintain/concerns/system_helpers.rb +18 -10
- data/lib/foreman_maintain/package_manager/apt.rb +71 -0
- data/lib/foreman_maintain/package_manager/yum.rb +8 -4
- data/lib/foreman_maintain/package_manager.rb +6 -4
- data/lib/foreman_maintain/reporter/cli_reporter.rb +24 -6
- data/lib/foreman_maintain/repository_manager/el.rb +15 -4
- data/lib/foreman_maintain/repository_manager.rb +1 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -0
- metadata +9 -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
@@ -0,0 +1,71 @@
|
|
1
|
+
module ForemanMaintain::PackageManager
|
2
|
+
class Apt < Base
|
3
|
+
def installed?(packages)
|
4
|
+
packages_list = [packages].flatten(1).map { |pkg| "'#{pkg}'" }.join(' ')
|
5
|
+
status, output = sys.execute_with_status(%(dpkg --status #{packages_list}))
|
6
|
+
return false if status != 0
|
7
|
+
|
8
|
+
status_of_pkg = output.split("\n").grep(/^Status:/).first
|
9
|
+
status_of_pkg.include?('installed')
|
10
|
+
end
|
11
|
+
|
12
|
+
def install(packages, assumeyes: false)
|
13
|
+
apt_action('install', packages, :assumeyes => assumeyes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def remove(packages, assumeyes: false)
|
17
|
+
apt_action('remove', packages, :assumeyes => assumeyes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(packages = [], assumeyes: false)
|
21
|
+
action = packages.any? ? '--only-upgrade install' : 'upgrade'
|
22
|
+
apt_action(action, packages, :assumeyes => assumeyes)
|
23
|
+
end
|
24
|
+
|
25
|
+
def clean_cache(assumeyes: false)
|
26
|
+
apt_action('clean', :assumeyes => assumeyes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def find_installed_package(name, queryfm = '')
|
30
|
+
return unless installed?(name)
|
31
|
+
|
32
|
+
dpkg_cmd = "dpkg-query --show #{name}"
|
33
|
+
unless queryfm.empty?
|
34
|
+
dpkg_cmd = "dpkg-query --showformat='#{queryfm}' --show #{name}"
|
35
|
+
end
|
36
|
+
_, result = sys.execute_with_status(dpkg_cmd)
|
37
|
+
result
|
38
|
+
end
|
39
|
+
|
40
|
+
def check_update(packages: nil, with_status: false)
|
41
|
+
apt_action('upgrade --dry-run', packages, :with_status => with_status)
|
42
|
+
end
|
43
|
+
|
44
|
+
def list_installed_packages(queryfm = '${binary:Package}-${VERSION}\n')
|
45
|
+
# The queryfm should only include valid tag(s) as per `dpkg-query` man page.
|
46
|
+
# If any special formatting is required with querytag then it should be provided with tag i.e,
|
47
|
+
# querytag = "--%{VERSION}"
|
48
|
+
# The queryfm string must end with '\n'
|
49
|
+
sys.execute!("dpkg-query --showformat='#{queryfm}' -W").split("\n")
|
50
|
+
end
|
51
|
+
|
52
|
+
def version_locking_supported?
|
53
|
+
false
|
54
|
+
end
|
55
|
+
|
56
|
+
def apt_action(action, packages, with_status: false, assumeyes: false, valid_exit_statuses: [0])
|
57
|
+
apt_options = []
|
58
|
+
packages = [packages].flatten(1)
|
59
|
+
apt_options << '-y' if assumeyes
|
60
|
+
apt_options_s = apt_options.empty? ? '' : ' ' + apt_options.join(' ')
|
61
|
+
packages_s = packages.empty? ? '' : ' ' + packages.join(' ')
|
62
|
+
if with_status
|
63
|
+
sys.execute_with_status("apt-get#{apt_options_s} #{action}#{packages_s}",
|
64
|
+
:interactive => !assumeyes)
|
65
|
+
else
|
66
|
+
sys.execute!("apt-get#{apt_options_s} #{action}#{packages_s}",
|
67
|
+
:interactive => !assumeyes, :valid_exit_statuses => valid_exit_statuses)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -59,8 +59,8 @@ module ForemanMaintain::PackageManager
|
|
59
59
|
yum_action('remove', packages, :assumeyes => assumeyes)
|
60
60
|
end
|
61
61
|
|
62
|
-
def update(packages = [], assumeyes: false)
|
63
|
-
yum_action('update', packages, :assumeyes => assumeyes)
|
62
|
+
def update(packages = [], assumeyes: false, yum_options: [])
|
63
|
+
yum_action('update', packages, :assumeyes => assumeyes, :yum_options => yum_options)
|
64
64
|
end
|
65
65
|
|
66
66
|
def clean_cache(assumeyes: false)
|
@@ -120,8 +120,12 @@ module ForemanMaintain::PackageManager
|
|
120
120
|
File.open(protector_config_file, 'w') { |file| file.puts config }
|
121
121
|
end
|
122
122
|
|
123
|
-
|
124
|
-
|
123
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
124
|
+
def yum_action(action, packages, options)
|
125
|
+
with_status = options.fetch(:with_status, false)
|
126
|
+
assumeyes = options.fetch(:assumeyes, false)
|
127
|
+
valid_exit_statuses = options.fetch(:valid_exit_statuses, [0])
|
128
|
+
yum_options = options.fetch(:yum_options, [])
|
125
129
|
packages = [packages].flatten(1)
|
126
130
|
yum_options << '-y' if assumeyes
|
127
131
|
yum_options << '--disableplugin=foreman-protector'
|
@@ -1,14 +1,16 @@
|
|
1
1
|
require 'foreman_maintain/package_manager/base'
|
2
2
|
require 'foreman_maintain/package_manager/yum'
|
3
3
|
require 'foreman_maintain/package_manager/dnf'
|
4
|
+
require 'foreman_maintain/package_manager/apt'
|
4
5
|
|
5
6
|
module ForemanMaintain
|
6
7
|
def self.package_manager
|
7
|
-
@package_manager ||=
|
8
|
-
when 'dnf'
|
9
|
-
ForemanMaintain::PackageManager::Dnf.new
|
10
|
-
when 'yum'
|
8
|
+
@package_manager ||= if el7?
|
11
9
|
ForemanMaintain::PackageManager::Yum.new
|
10
|
+
elsif el?
|
11
|
+
ForemanMaintain::PackageManager::Dnf.new
|
12
|
+
elsif debian_or_ubuntu?
|
13
|
+
ForemanMaintain::PackageManager::Apt.new
|
12
14
|
else
|
13
15
|
raise 'No supported package manager was found'
|
14
16
|
end
|
@@ -317,7 +317,11 @@ module ForemanMaintain
|
|
317
317
|
|
318
318
|
steps_with_error = scenario.steps_with_error(:whitelisted => false)
|
319
319
|
steps_with_skipped = scenario.steps_with_skipped(:whitelisted => true)
|
320
|
-
|
320
|
+
not_skippable_steps = scenario.steps_with_error.select do |step|
|
321
|
+
step.metadata[:do_not_whitelist] == true
|
322
|
+
end
|
323
|
+
|
324
|
+
steps_to_whitelist = steps_with_error + steps_with_skipped - not_skippable_steps
|
321
325
|
unless steps_with_error.empty?
|
322
326
|
message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
|
323
327
|
The following steps ended up in failing state:
|
@@ -325,11 +329,25 @@ module ForemanMaintain
|
|
325
329
|
%s
|
326
330
|
MESSAGE
|
327
331
|
whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
332
|
+
unless whitelist_labels.empty?
|
333
|
+
recommend << if scenario.detector.feature(:instance).downstream
|
334
|
+
format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
335
|
+
Resolve the failed steps and rerun the command.
|
336
|
+
|
337
|
+
If the situation persists and, you are unclear what to do next,
|
338
|
+
contact Red Hat Technical Support.
|
339
|
+
|
340
|
+
In case the failures are false positives, use
|
341
|
+
--whitelist="%s"
|
342
|
+
MESSAGE
|
343
|
+
else
|
344
|
+
format(<<-MESSAGE.strip_heredoc, whitelist_labels)
|
345
|
+
Resolve the failed steps and rerun the command.
|
346
|
+
In case the failures are false positives, use
|
347
|
+
--whitelist="%s"
|
348
|
+
MESSAGE
|
349
|
+
end
|
350
|
+
end
|
333
351
|
end
|
334
352
|
|
335
353
|
steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
|
@@ -76,10 +76,21 @@ module ForemanMaintain::RepositoryManager
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def hash_of_repoids_urls(repos, regex)
|
79
|
-
Hash[*repos.split("\n").grep(regex).map do |entry|
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
ids_urls = Hash[*repos.split("\n").grep(regex).map do |entry|
|
80
|
+
entry.split(':', 2).last.strip
|
81
|
+
end]
|
82
|
+
|
83
|
+
# The EL7 yum repolist output includes extra info in the output,
|
84
|
+
# as example
|
85
|
+
# rhel-7-server-rpms/7Server/x86_64
|
86
|
+
# rhel-server-rhscl-7-rpms/7Server/x86_64
|
87
|
+
# This trims anything after first '/' to get correct repo label
|
88
|
+
trimmed_hash = {}
|
89
|
+
ids_urls.each do |id, url|
|
90
|
+
trimmed_id = id.split('/').first
|
91
|
+
trimmed_hash[trimmed_id] = url
|
92
|
+
end
|
93
|
+
trimmed_hash
|
83
94
|
end
|
84
95
|
end
|
85
96
|
end
|
data/lib/foreman_maintain.rb
CHANGED
@@ -26,6 +26,7 @@ module ForemanMaintain
|
|
26
26
|
require 'foreman_maintain/concerns/pulp_common'
|
27
27
|
require 'foreman_maintain/concerns/firewall/iptables_maintenance_mode'
|
28
28
|
require 'foreman_maintain/concerns/firewall/nftables_maintenance_mode'
|
29
|
+
require 'foreman_maintain/concerns/firewall/maintenance_mode'
|
29
30
|
require 'foreman_maintain/top_level_modules'
|
30
31
|
require 'foreman_maintain/yaml_storage'
|
31
32
|
require 'foreman_maintain/config'
|
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.4
|
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-14 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
|
@@ -266,6 +263,7 @@ files:
|
|
266
263
|
- definitions/procedures/foreman_tasks/ui_investigate.rb
|
267
264
|
- definitions/procedures/hammer_setup.rb
|
268
265
|
- definitions/procedures/installer/run.rb
|
266
|
+
- definitions/procedures/installer/run_for_6_11.rb
|
269
267
|
- definitions/procedures/installer/upgrade.rb
|
270
268
|
- definitions/procedures/installer/upgrade_rake_task.rb
|
271
269
|
- definitions/procedures/knowledge_base_article.rb
|
@@ -280,7 +278,6 @@ files:
|
|
280
278
|
- definitions/procedures/packages/unlock_versions.rb
|
281
279
|
- definitions/procedures/packages/update.rb
|
282
280
|
- definitions/procedures/packages/update_all_confirmation.rb
|
283
|
-
- definitions/procedures/passenger_recycler.rb
|
284
281
|
- definitions/procedures/prep_6_10_upgrade.rb
|
285
282
|
- definitions/procedures/pulp/cleanup_old_metadata_files.rb
|
286
283
|
- definitions/procedures/pulp/migrate.rb
|
@@ -335,6 +332,8 @@ files:
|
|
335
332
|
- definitions/scenarios/upgrade_to_capsule_6_10_z.rb
|
336
333
|
- definitions/scenarios/upgrade_to_capsule_6_11.rb
|
337
334
|
- definitions/scenarios/upgrade_to_capsule_6_11_z.rb
|
335
|
+
- definitions/scenarios/upgrade_to_capsule_6_12.rb
|
336
|
+
- definitions/scenarios/upgrade_to_capsule_6_12_z.rb
|
338
337
|
- definitions/scenarios/upgrade_to_capsule_6_8.rb
|
339
338
|
- definitions/scenarios/upgrade_to_capsule_6_8_z.rb
|
340
339
|
- definitions/scenarios/upgrade_to_capsule_6_9.rb
|
@@ -343,6 +342,8 @@ files:
|
|
343
342
|
- definitions/scenarios/upgrade_to_satellite_6_10_z.rb
|
344
343
|
- definitions/scenarios/upgrade_to_satellite_6_11.rb
|
345
344
|
- definitions/scenarios/upgrade_to_satellite_6_11_z.rb
|
345
|
+
- definitions/scenarios/upgrade_to_satellite_6_12.rb
|
346
|
+
- definitions/scenarios/upgrade_to_satellite_6_12_z.rb
|
346
347
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
347
348
|
- definitions/scenarios/upgrade_to_satellite_6_2_z.rb
|
348
349
|
- definitions/scenarios/upgrade_to_satellite_6_3.rb
|
@@ -364,7 +365,6 @@ files:
|
|
364
365
|
- extras/foreman_protector/foreman-protector.conf
|
365
366
|
- extras/foreman_protector/foreman-protector.whitelist
|
366
367
|
- extras/foreman_protector/yum/foreman-protector.py
|
367
|
-
- extras/passenger-recycler.cron
|
368
368
|
- lib/foreman_maintain.rb
|
369
369
|
- lib/foreman_maintain/check.rb
|
370
370
|
- lib/foreman_maintain/cli.rb
|
@@ -392,6 +392,7 @@ files:
|
|
392
392
|
- lib/foreman_maintain/concerns/downstream.rb
|
393
393
|
- lib/foreman_maintain/concerns/finders.rb
|
394
394
|
- lib/foreman_maintain/concerns/firewall/iptables_maintenance_mode.rb
|
395
|
+
- lib/foreman_maintain/concerns/firewall/maintenance_mode.rb
|
395
396
|
- lib/foreman_maintain/concerns/firewall/nftables_maintenance_mode.rb
|
396
397
|
- lib/foreman_maintain/concerns/hammer.rb
|
397
398
|
- lib/foreman_maintain/concerns/logger.rb
|
@@ -413,6 +414,7 @@ files:
|
|
413
414
|
- lib/foreman_maintain/executable.rb
|
414
415
|
- lib/foreman_maintain/feature.rb
|
415
416
|
- lib/foreman_maintain/package_manager.rb
|
417
|
+
- lib/foreman_maintain/package_manager/apt.rb
|
416
418
|
- lib/foreman_maintain/package_manager/base.rb
|
417
419
|
- lib/foreman_maintain/package_manager/dnf.rb
|
418
420
|
- lib/foreman_maintain/package_manager/yum.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
|