fix(memstrack): drop bash runtime requirement
Use nohup instead of disown, and let systemd track the service properly. This makes the scripts POSIX compatible and bash is no longer needed. Signed-off-by: Kairui Song <kasong@tencent.com>master
parent
b3d2dcb71e
commit
35822f3997
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# Mount kernel debug fs so debug tools can work.
|
# Mount kernel debug fs so debug tools can work.
|
||||||
# memdebug=4 and memdebug=5 requires debug fs to be mounted.
|
# memdebug=4 and memdebug=5 requires debug fs to be mounted.
|
||||||
# And there is no need to umount it.
|
# And there is no need to umount it.
|
||||||
|
@ -20,8 +20,6 @@ is_debugfs_ready() {
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_debugfs() {
|
prepare_debugfs() {
|
||||||
local trace_base
|
|
||||||
|
|
||||||
trace_base=$(get_trace_base)
|
trace_base=$(get_trace_base)
|
||||||
# old debugfs interface case.
|
# old debugfs interface case.
|
||||||
if ! [ -d "$trace_base/tracing" ]; then
|
if ! [ -d "$trace_base/tracing" ]; then
|
||||||
|
@ -44,10 +42,10 @@ fi
|
||||||
if [ -n "$DEBUG_MEM_LEVEL" ]; then
|
if [ -n "$DEBUG_MEM_LEVEL" ]; then
|
||||||
if [ "$DEBUG_MEM_LEVEL" -ge 5 ]; then
|
if [ "$DEBUG_MEM_LEVEL" -ge 5 ]; then
|
||||||
echo "memstrack - will report kernel module memory usage summary and top allocation stack"
|
echo "memstrack - will report kernel module memory usage summary and top allocation stack"
|
||||||
memstrack --report module_summary,module_top --notui --throttle 80 -o /.memstrack &
|
nohup memstrack --report module_summary,module_top --notui --throttle 80 -o /.memstrack > /dev/null &
|
||||||
elif [ "$DEBUG_MEM_LEVEL" -ge 4 ]; then
|
elif [ "$DEBUG_MEM_LEVEL" -ge 4 ]; then
|
||||||
echo "memstrack - will report memory usage summary"
|
echo "memstrack - will report memory usage summary"
|
||||||
memstrack --report module_summary --notui --throttle 80 -o /.memstrack &
|
nohup memstrack --report module_summary --notui --throttle 80 -o /.memstrack > /dev/null &
|
||||||
else
|
else
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -61,9 +59,7 @@ if [ $RET -ne 0 ]; then
|
||||||
exit $RET
|
exit $RET
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo $PID > /run/memstrack.pid
|
||||||
|
|
||||||
# Wait a second for memstrack to setup everything, avoid missing any event
|
# Wait a second for memstrack to setup everything, avoid missing any event
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
echo $PID > /run/memstrack.pid
|
|
||||||
# bash specific - non posix
|
|
||||||
disown
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ ConditionKernelCommandLine=|rd.memdebug=4
|
||||||
ConditionKernelCommandLine=|rd.memdebug=5
|
ConditionKernelCommandLine=|rd.memdebug=5
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=forking
|
||||||
ExecStart=/bin/memstrack-start
|
ExecStart=/bin/memstrack-start
|
||||||
PIDFile=/run/memstrack.pid
|
PIDFile=/run/memstrack.pid
|
||||||
StandardInput=null
|
StandardInput=null
|
||||||
|
|
|
@ -11,12 +11,12 @@ check() {
|
||||||
}
|
}
|
||||||
|
|
||||||
depends() {
|
depends() {
|
||||||
echo systemd bash
|
echo systemd
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
inst_multiple pgrep pkill
|
inst_multiple pgrep pkill nohup
|
||||||
inst "/bin/memstrack" "/bin/memstrack"
|
inst "/bin/memstrack" "/bin/memstrack"
|
||||||
|
|
||||||
inst "$moddir/memstrack-start.sh" "/bin/memstrack-start"
|
inst "$moddir/memstrack-start.sh" "/bin/memstrack-start"
|
||||||
|
|
Loading…
Reference in New Issue