diff options
author | Andrew Cady <d@cryptonomic.net> | 2022-04-04 10:29:05 -0400 |
---|---|---|
committer | Andrew Cady <d@cryptonomic.net> | 2022-04-04 10:34:20 -0400 |
commit | f887aebab9b0a25e1151b492cf131c391f33dab6 (patch) | |
tree | 123ef2269c54754d7552759fa800876cb4765694 | |
parent | 7c17d07ac3c9213565345c6cf75cced5b592c318 (diff) |
assume firestart cgroup layout
also:
ioslay-mgr will warn once when ff is not running, but not
spam logs with errors
-rwxr-xr-x | fireslay | 6 | ||||
-rwxr-xr-x | firestart | 16 | ||||
-rwxr-xr-x | ioslay-mgr.sh | 53 | ||||
-rwxr-xr-x | sliceweasel.lib.sh | 7 |
4 files changed, 47 insertions, 35 deletions
@@ -83,11 +83,7 @@ web_content_pids() | |||
83 | done < $FIREFOX_GROUP_PROCS | 83 | done < $FIREFOX_GROUP_PROCS |
84 | } | 84 | } |
85 | 85 | ||
86 | uid=$(get_uid) | 86 | FIREFOX_GROUP_PROCS=$(get_firefox_cgroup_procs) |
87 | group=user.slice/user-$uid.slice/firefox | ||
88 | group_procs=/sys/fs/cgroup/$group/cgroup.procs | ||
89 | |||
90 | FIREFOX_GROUP_PROCS=$group_procs | ||
91 | if [ -e "$FIREFOX_GROUP_PROCS" ] | 87 | if [ -e "$FIREFOX_GROUP_PROCS" ] |
92 | then | 88 | then |
93 | main "$@" | 89 | main "$@" |
@@ -18,13 +18,13 @@ DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n)) | |||
18 | 18 | ||
19 | systemctl --user reset-failed "$UNIT" 2>/dev/null | 19 | systemctl --user reset-failed "$UNIT" 2>/dev/null |
20 | systemd-run --user \ | 20 | systemd-run --user \ |
21 | --unit="$UNIT" \ | 21 | --unit "$UNIT" \ |
22 | --setenv=DISPLAY="$DISPLAY" \ | 22 | --setenv DISPLAY="$DISPLAY" \ |
23 | --setenv=XAUTHORITY="$XAUTHORITY" \ | 23 | --setenv XAUTHORITY="$XAUTHORITY" \ |
24 | --property=MemoryMax="$MEMORY_MAX" \ | 24 | --property MemoryMax="$MEMORY_MAX" \ |
25 | --property=IOReadIOPSMax="$DEV $READ_OPS" \ | 25 | --property IOReadIOPSMax="$DEV $READ_OPS" \ |
26 | --property=IOWriteIOPSMax="$DEV $WRITE_OPS" \ | 26 | --property IOWriteIOPSMax="$DEV $WRITE_OPS" \ |
27 | --property=IOWriteIOPSMax="$DEV $WRITE_OPS" \ | 27 | --property IOWriteIOPSMax="$DEV $WRITE_OPS" \ |
28 | --property=Restart="on-failure" \ | 28 | --property Restart="on-failure" \ |
29 | -- \ | 29 | -- \ |
30 | "$CMD" "$@" | 30 | "$CMD" "$@" |
diff --git a/ioslay-mgr.sh b/ioslay-mgr.sh index 556fe74..7d6461f 100755 --- a/ioslay-mgr.sh +++ b/ioslay-mgr.sh | |||
@@ -36,10 +36,8 @@ slay_slayer() | |||
36 | 36 | ||
37 | GROUP_BASENAME=firefox | 37 | GROUP_BASENAME=firefox |
38 | 38 | ||
39 | uid=$(set -x; get_uid) | 39 | group_procs=$(get_firefox_cgroup_procs) |
40 | uid=1000 | 40 | |
41 | group=user.slice/user-$uid.slice/$GROUP_BASENAME | ||
42 | group_procs=/sys/fs/cgroup/$group/cgroup.procs | ||
43 | wantcomm='Web Content' | 41 | wantcomm='Web Content' |
44 | ioslay= | 42 | ioslay= |
45 | lastprocs= | 43 | lastprocs= |
@@ -47,28 +45,39 @@ SIGNALLED= | |||
47 | trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP | 45 | trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP |
48 | while [ ! "$SIGNALLED" ] | 46 | while [ ! "$SIGNALLED" ] |
49 | do | 47 | do |
50 | read -N 1000100 procs < "$group_procs" | 48 | if ! [ -e "$group_procs" ] |
51 | if [ "$procs" ] | ||
52 | then | 49 | then |
53 | set -- | 50 | [ "$warned" ] || echo "Warning: firefox not running or cgroup not found" >&2 |
54 | for pid in $procs | 51 | warned=y |
55 | do | 52 | else |
56 | read comm < /proc/$pid/comm | 53 | if [ "$warned" ] |
57 | if [ "$comm" = "$wantcomm" ] | 54 | then |
55 | echo "Found firefox cgroup: $group_procs" >&2 | ||
56 | warned= | ||
57 | fi | ||
58 | read -N 1000100 procs < "$group_procs" | ||
59 | if [ "$procs" ] | ||
60 | then | ||
61 | set -- | ||
62 | for pid in $procs | ||
63 | do | ||
64 | read comm < /proc/$pid/comm | ||
65 | if [ "$comm" = "$wantcomm" ] | ||
66 | then | ||
67 | set -- "$@" "$pid" | ||
68 | fi | ||
69 | done | ||
70 | |||
71 | # echo "pids: ($*|$(echo $procs))" >&2 | ||
72 | if [ "$lastargs" != "$*" ] | ||
58 | then | 73 | then |
59 | set -- "$@" "$pid" | 74 | slay_slayer |
75 | wait $ioslay | ||
76 | ioslay-firefox "$@" & | ||
77 | ioslay=$! | ||
60 | fi | 78 | fi |
61 | done | 79 | lastargs=$* |
62 | |||
63 | # echo "pids: ($*|$(echo $procs))" >&2 | ||
64 | if [ "$lastargs" != "$*" ] | ||
65 | then | ||
66 | slay_slayer | ||
67 | wait $ioslay | ||
68 | ioslay-firefox "$@" & | ||
69 | ioslay=$! | ||
70 | fi | 80 | fi |
71 | lastargs=$* | ||
72 | fi | 81 | fi |
73 | sleep 1 | 82 | sleep 1 |
74 | done | 83 | done |
diff --git a/sliceweasel.lib.sh b/sliceweasel.lib.sh index 28091a0..d9a93c5 100755 --- a/sliceweasel.lib.sh +++ b/sliceweasel.lib.sh | |||
@@ -134,6 +134,13 @@ get_uid() | |||
134 | ) | 134 | ) |
135 | } | 135 | } |
136 | 136 | ||
137 | get_firefox_cgroup_procs() | ||
138 | { | ||
139 | uid=$(get_uid) | ||
140 | [ "$uid" ] || return | ||
141 | echo /sys/fs/cgroup/user.slice/user-$uid.slice/user@$uid.service/app.slice/firefox.service/cgroup.procs | ||
142 | } | ||
143 | |||
137 | get_current_group() | 144 | get_current_group() |
138 | { | 145 | { |
139 | read g < /proc/$$/cgroup | 146 | read g < /proc/$$/cgroup |