blob: 649e200705e404f2d08e40f5a81c821214632389 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/sh /etc/rc.common
# shellcheck disable=SC3043
START=50
USE_PROCD=1
start_service() {
config_load 'earlyoom'
for opt in memory_term_percent memory_kill_percent \
swap_term_percent swap_kill_percent memory_term_kib \
memory_kill_kib swap_term_kib swap_kill_kib prefer_regex \
avoid_regex ignore_regex report_interval \
pre_script_path post_script_path
do
local "$opt"
config_get "$opt" 'main' "$opt"
done
for opt in debug_log high_priority kill_process_group \
sort_by_rss dry_run syslog
do
local "$opt"
config_get_bool "$opt" 'main' "$opt" 0
done
procd_open_instance
procd_set_param command '/usr/sbin/earlyoom'
procd_set_param stderr 1
procd_set_param respawn
[ "$memory_term_percent" -gt '0' ] || [ "$memory_kill_percent" -gt '0' ] &&
procd_append_param command -m "$memory_term_percent","$memory_kill_percent"
[ "$swap_term_percent" -gt '0' ] || [ "$swap_kill_percent" -gt '0' ] &&
procd_append_param command -s "$swap_term_percent","$swap_kill_percent"
[ "$memory_term_kib" -gt '0' ] || [ "$memory_kill_kib" -gt '0' ] &&
procd_append_param command -M "$memory_term_kib","$memory_kill_kib"
[ "$swap_term_kib" -gt '0' ] || [ "$swap_kill_kib" -gt '0' ] &&
procd_append_param command -S "$swap_term_kib","$swap_kill_kib"
[ -n "$prefer_regex" ] && procd_append_param command --prefer "$prefer_regex"
[ -n "$avoid_regex" ] && procd_append_param command --avoid "$avoid_regex"
[ -n "$ignore_regex" ] && procd_append_param command --ignore "$ignore_regex"
[ -x "$pre_script_path" ] && procd_append_param command -P "$pre_script_path"
[ -x "$post_script_path" ] && procd_append_param command -N "$post_script_path"
[ -n "$report_interval" ] && procd_append_param command -r "$report_interval"
[ "$debug_log" -eq '1' ] && procd_append_param command -d
[ "$high_priority" -eq '1' ] && procd_append_param command -p
[ "$kill_process_group" -eq '1' ] && procd_append_param command -g
[ "$sort_by_rss" -eq '1' ] && procd_append_param command --sort-by-rss
[ "$dry_run" -eq '1' ] && procd_append_param command --dryrun
[ "$syslog" -eq '1' ] && procd_append_param command --syslog
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger 'earlyoom'
}
|