fix logging: flush stdout

This commit is contained in:
Alexey Avramov 2018-07-26 00:00:20 +09:00
parent 5ca9f249b1
commit 2cca1e9975
6 changed files with 19 additions and 24 deletions

View File

@ -50,7 +50,7 @@ Also look at [Why are low memory conditions handled so badly?](https://www.reddi
## Memory and CPU usage ## Memory and CPU usage
- VmRSS is 10 — 14 MiB depending on the settings - VmRSS is 10 — 13 MiB depending on the settings (about 10 MiB by default)
- CPU usage depends on the level of available memory (the frequency of memory status checks increases as the amount of available memory decreases) and monitoring intensity (can be changed by user via config) - CPU usage depends on the level of available memory (the frequency of memory status checks increases as the amount of available memory decreases) and monitoring intensity (can be changed by user via config)
## Status ## Status

View File

@ -5,10 +5,10 @@
1. Memory levels to respond to as an OOM threat 1. Memory levels to respond to as an OOM threat
mem_min_sigterm = 9 % mem_min_sigterm = 10 %
mem_min_sigkill = 6 % mem_min_sigkill = 5 %
swap_min_sigterm = 9 % swap_min_sigterm = 10 %
swap_min_sigkill = 6 % swap_min_sigkill = 5 %
zram_max_sigterm = 50 % zram_max_sigterm = 50 %
zram_max_sigkill = 55 % zram_max_sigkill = 55 %
@ -29,7 +29,7 @@ min_badness = 10
min_delay_after_sigterm = 0.5 min_delay_after_sigterm = 0.5
min_delay_after_sigkill = 3 min_delay_after_sigkill = 3
decrease_oom_score_adj = False decrease_oom_score_adj = False
oom_score_adj_max = 20 oom_score_adj_max = 30
##################################################################### #####################################################################
@ -48,7 +48,7 @@ avoid_factor = 3
SIGTERM signal. SIGTERM signal.
execute_the_command = False execute_the_command = False
** processname :: some command $ETC proc_name /// some command
##################################################################### #####################################################################

9
nohang
View File

@ -6,7 +6,7 @@ import os
from operator import itemgetter from operator import itemgetter
from time import sleep, time from time import sleep, time
from argparse import ArgumentParser from argparse import ArgumentParser
# from subprocess import Popen from sys import stdout
sig_dict = {9: 'SIGKILL', 15: 'SIGTERM'} sig_dict = {9: 'SIGKILL', 15: 'SIGTERM'}
@ -457,8 +457,7 @@ else:
exit() exit()
print('The path to the config file to be used:') print('The path to the config file to be used:', config)
print(config)
########################################################################## ##########################################################################
@ -1252,7 +1251,7 @@ warn_time_now = 0
warn_time_delta = 1000 warn_time_delta = 1000
warn_timer = 0 warn_timer = 0
print('\nStart monitoring...') print('Start monitoring...')
########################################################################## ##########################################################################
@ -1431,7 +1430,7 @@ while True:
# SLEEP BETWEEN MEM CHECKS # SLEEP BETWEEN MEM CHECKS
else: else:
stdout.flush()
sleep_after_check_mem() sleep_after_check_mem()

View File

@ -7,7 +7,7 @@ nohang \- no hang daemon
.RB [ OPTION ]... .RB [ OPTION ]...
.SH DESCRIPTION .SH DESCRIPTION
Nohang is a highly configurable daemon for Linux which is able to correctly prevent out of memory conditions. See https://github.com/hakavlad/nohang Nohang is a highly configurable daemon for Linux which is able to correctly prevent out of memory (OOM) and keep system responsiveness in low memory conditions. See https://github.com/hakavlad/nohang
.SH OPTIONS .SH OPTIONS
.TP .TP

View File

@ -34,13 +34,13 @@
MemAvailable levels. MemAvailable levels.
mem_min_sigterm = 9 % mem_min_sigterm = 10 %
mem_min_sigkill = 6 % mem_min_sigkill = 5 %
SwapFree levels. SwapFree levels.
swap_min_sigterm = 9 % swap_min_sigterm = 10 %
swap_min_sigkill = 6 % swap_min_sigkill = 5 %
Specifying the total share of zram in memory, if exceeded the Specifying the total share of zram in memory, if exceeded the
corresponding signals are sent. As the share of zram in memory corresponding signals are sent. As the share of zram in memory
@ -114,7 +114,7 @@ decrease_oom_score_adj = False
Valid values are integers from the range [0; 1000]. Valid values are integers from the range [0; 1000].
oom_score_adj_max = 20 oom_score_adj_max = 30
##################################################################### #####################################################################
@ -275,7 +275,7 @@ oom_score_adj = -100
Read `man ionice` to understand the following parameters. Read `man ionice` to understand the following parameters.
Setting the True value requires the root privileges. Setting the True value requires the root privileges.
realtime_ionice = True realtime_ionice = False
'For realtime and best-effort, 0-7 are valid data 'For realtime and best-effort, 0-7 are valid data
(priority levels), and 0 represents the highest priority level.' (priority levels), and 0 represents the highest priority level.'
@ -291,7 +291,7 @@ realtime_ionice_classdata = 5
Display the configuration when the program starts. Display the configuration when the program starts.
Valid values are True and False. Valid values are True and False.
print_config = True print_config = False
Print memory check results or not print. Print memory check results or not print.
Valid values are True and False. Valid values are True and False.

View File

@ -5,10 +5,6 @@ After=sysinit.target
Documentation=man:nohang(1) https://github.com/hakavlad/nohang Documentation=man:nohang(1) https://github.com/hakavlad/nohang
[Service] [Service]
Type=simple
Restart=always
StandardOutput=syslog
StandardError=syslog
ExecStart=/usr/local/bin/nohang ExecStart=/usr/local/bin/nohang
[Install] [Install]