summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2022-04-04 10:29:05 -0400
committerAndrew Cady <d@cryptonomic.net>2022-04-04 10:34:20 -0400
commitf887aebab9b0a25e1151b492cf131c391f33dab6 (patch)
tree123ef2269c54754d7552759fa800876cb4765694
parent7c17d07ac3c9213565345c6cf75cced5b592c318 (diff)
assume firestart cgroup layout
also: ioslay-mgr will warn once when ff is not running, but not spam logs with errors
-rwxr-xr-xfireslay6
-rwxr-xr-xfirestart16
-rwxr-xr-xioslay-mgr.sh53
-rwxr-xr-xsliceweasel.lib.sh7
4 files changed, 47 insertions, 35 deletions
diff --git a/fireslay b/fireslay
index ef1e4f4..892dbee 100755
--- a/fireslay
+++ b/fireslay
@@ -83,11 +83,7 @@ web_content_pids()
83 done < $FIREFOX_GROUP_PROCS 83 done < $FIREFOX_GROUP_PROCS
84} 84}
85 85
86uid=$(get_uid) 86FIREFOX_GROUP_PROCS=$(get_firefox_cgroup_procs)
87group=user.slice/user-$uid.slice/firefox
88group_procs=/sys/fs/cgroup/$group/cgroup.procs
89
90FIREFOX_GROUP_PROCS=$group_procs
91if [ -e "$FIREFOX_GROUP_PROCS" ] 87if [ -e "$FIREFOX_GROUP_PROCS" ]
92then 88then
93 main "$@" 89 main "$@"
diff --git a/firestart b/firestart
index 5be6d02..ce4aa54 100755
--- a/firestart
+++ b/firestart
@@ -18,13 +18,13 @@ DEV=$(echo $(findmnt --target "$DIR" -o MAJ:MIN -n))
18 18
19systemctl --user reset-failed "$UNIT" 2>/dev/null 19systemctl --user reset-failed "$UNIT" 2>/dev/null
20systemd-run --user \ 20systemd-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
37GROUP_BASENAME=firefox 37GROUP_BASENAME=firefox
38 38
39uid=$(set -x; get_uid) 39group_procs=$(get_firefox_cgroup_procs)
40uid=1000 40
41group=user.slice/user-$uid.slice/$GROUP_BASENAME
42group_procs=/sys/fs/cgroup/$group/cgroup.procs
43wantcomm='Web Content' 41wantcomm='Web Content'
44ioslay= 42ioslay=
45lastprocs= 43lastprocs=
@@ -47,28 +45,39 @@ SIGNALLED=
47trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP 45trap 'SIGNALLED=y' SIGINT SIGTERM SIGHUP
48while [ ! "$SIGNALLED" ] 46while [ ! "$SIGNALLED" ]
49do 47do
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
74done 83done
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
137get_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
137get_current_group() 144get_current_group()
138{ 145{
139 read g < /proc/$$/cgroup 146 read g < /proc/$$/cgroup