Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Change mainloop logic
Browse files Browse the repository at this point in the history
Signed-off-by: Timofey Titovets <[email protected]>
  • Loading branch information
nefelim4ag committed May 6, 2017
1 parent 29a505e commit 6cacf27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions ananicy
Original file line number Diff line number Diff line change
Expand Up @@ -282,25 +282,25 @@ case $1 in
check_schedulers
check_bins
INFO "Start main process"
CHECK_FREQ=${CHECK_FREQ:-15}
while sleep $CHECK_FREQ; do
CHECK_FREQ=${CHECK_FREQ:-0.2s}
for RULE in RULES_CACHE/*; do
[ ! -d "$WORK_DIR" ] && break
for FILE in RULES_CACHE/*; do
[ ! -f "$FILE" ] && continue
unset NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ
export NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ
source "$FILE"
NAME="${NAME//\"/}"
for PID in $( pgrep -f -w "$NAME" ); do
[ -z "$PID" ] && return
[ ! -d "/proc/$PID" ] && continue
[ ! -z "$NICE" ] && renice_w
[ ! -z "$IOCLASS" ] && ionice_class_w
[ ! -z "$IONICE" ] && ionice_w
[ ! -z "$SCHED" ] && schedtool_policy_w
[ ! -z "$OOM_SCORE_ADJ" ] && oom_score_adj_w
done
[ ! -f "$RULE" ] && continue
unset NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ
export NAME PID NICE IOCLASS IONICE SCHED OOM_SCORE_ADJ
source "$RULE"
NAME="${NAME//\"/}"
for PID in $( pgrep -f -w "$NAME" ); do
[ -z "$PID" ] && return
[ ! -d "/proc/$PID" ] && continue
[ ! -z "$NICE" ] && renice_w
[ ! -z "$IOCLASS" ] && ionice_class_w
[ ! -z "$IONICE" ] && ionice_w
[ ! -z "$SCHED" ] && schedtool_policy_w
[ ! -z "$OOM_SCORE_ADJ" ] && oom_score_adj_w
done
# Pause before processing next rule
sleep $CHECK_FREQ
done
;;
stop) force_exit ;;
Expand Down
2 changes: 1 addition & 1 deletion ananicy.d/ananicy.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Ananicy configuration
CHECK_FREQ=15s
CHECK_FREQ=0.2s

## Logging
INFO_MSG_NICE_ENABLED=true
Expand Down

0 comments on commit 6cacf27

Please sign in to comment.