From 2cca1e9975c390099e0ec48a9fd6404b2c83a69d Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Thu, 26 Jul 2018 00:00:20 +0900 Subject: [PATCH] fix logging: flush stdout --- README.md | 2 +- default_values_backup.conf | 12 ++++++------ nohang | 9 ++++----- nohang.1 | 2 +- nohang.conf | 14 +++++++------- nohang.service | 4 ---- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index bd327c6..dd48951 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Also look at [Why are low memory conditions handled so badly?](https://www.reddi ## 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) ## Status diff --git a/default_values_backup.conf b/default_values_backup.conf index c5dc0f3..ec50ef8 100644 --- a/default_values_backup.conf +++ b/default_values_backup.conf @@ -5,10 +5,10 @@ 1. Memory levels to respond to as an OOM threat -mem_min_sigterm = 9 % -mem_min_sigkill = 6 % -swap_min_sigterm = 9 % -swap_min_sigkill = 6 % +mem_min_sigterm = 10 % +mem_min_sigkill = 5 % +swap_min_sigterm = 10 % +swap_min_sigkill = 5 % zram_max_sigterm = 50 % zram_max_sigkill = 55 % @@ -29,7 +29,7 @@ min_badness = 10 min_delay_after_sigterm = 0.5 min_delay_after_sigkill = 3 decrease_oom_score_adj = False -oom_score_adj_max = 20 +oom_score_adj_max = 30 ##################################################################### @@ -48,7 +48,7 @@ avoid_factor = 3 SIGTERM signal. execute_the_command = False -** processname :: some command +$ETC proc_name /// some command ##################################################################### diff --git a/nohang b/nohang index ea0f840..a3d90a0 100755 --- a/nohang +++ b/nohang @@ -6,7 +6,7 @@ import os from operator import itemgetter from time import sleep, time from argparse import ArgumentParser -# from subprocess import Popen +from sys import stdout sig_dict = {9: 'SIGKILL', 15: 'SIGTERM'} @@ -457,8 +457,7 @@ else: exit() -print('The path to the config file to be used:') -print(config) +print('The path to the config file to be used:', config) ########################################################################## @@ -1252,7 +1251,7 @@ warn_time_now = 0 warn_time_delta = 1000 warn_timer = 0 -print('\nStart monitoring...') +print('Start monitoring...') ########################################################################## @@ -1431,7 +1430,7 @@ while True: # SLEEP BETWEEN MEM CHECKS else: - + stdout.flush() sleep_after_check_mem() diff --git a/nohang.1 b/nohang.1 index c6ecf39..0a83360 100644 --- a/nohang.1 +++ b/nohang.1 @@ -7,7 +7,7 @@ nohang \- no hang daemon .RB [ OPTION ]... .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 .TP diff --git a/nohang.conf b/nohang.conf index f624a3d..c8cd151 100644 --- a/nohang.conf +++ b/nohang.conf @@ -34,13 +34,13 @@ MemAvailable levels. -mem_min_sigterm = 9 % -mem_min_sigkill = 6 % +mem_min_sigterm = 10 % +mem_min_sigkill = 5 % SwapFree levels. -swap_min_sigterm = 9 % -swap_min_sigkill = 6 % +swap_min_sigterm = 10 % +swap_min_sigkill = 5 % Specifying the total share of zram in memory, if exceeded the 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]. -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. Setting the True value requires the root privileges. -realtime_ionice = True +realtime_ionice = False 'For realtime and best-effort, 0-7 are valid data (priority levels), and 0 represents the highest priority level.' @@ -291,7 +291,7 @@ realtime_ionice_classdata = 5 Display the configuration when the program starts. Valid values are True and False. -print_config = True +print_config = False Print memory check results or not print. Valid values are True and False. diff --git a/nohang.service b/nohang.service index 9520164..523611b 100644 --- a/nohang.service +++ b/nohang.service @@ -5,10 +5,6 @@ After=sysinit.target Documentation=man:nohang(1) https://github.com/hakavlad/nohang [Service] -Type=simple -Restart=always -StandardOutput=syslog -StandardError=syslog ExecStart=/usr/local/bin/nohang [Install]