luci-app-unblockmusic: restart at everyday update avoid memory leak

This commit is contained in:
coolsnowwolf 2020-02-18 12:14:06 +08:00
parent 11eb685779
commit 7522b1e08e
4 changed files with 11 additions and 9 deletions

View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-unblockmusic
PKG_VERSION:=2.3.1
PKG_RELEASE:=11
PKG_RELEASE:=12
PKG_LICENSE:=Apache-2.0

View File

@ -62,7 +62,7 @@ o.inputtitle = translate("更新核心版本")
o.description = string.format(translate("目前运行主程序版本") .. "<strong><font color=\"green\">: %s </font></strong>", ver)
o.inputstyle = "reload"
o.write = function()
luci.sys.exec("/usr/share/UnblockNeteaseMusic/update_core.sh 2>&1")
luci.sys.exec("/usr/share/UnblockNeteaseMusic/update_core.sh luci_update 2>&1")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "unblockmusic"))
end

View File

@ -6,10 +6,8 @@ log_file="/tmp/unblockmusic.log"
while true
do
sleep 10s
icount=`busybox ps -w | grep UnblockNeteaseMusic/app.js |grep -v grep| wc -l`
if [ $icount -ne 1 ] ;then
/etc/init.d/unblockmusic restart
fi
icount=`busybox ps -w | grep UnblockNeteaseMusic/app.js |grep -v grep`
[ -z "$icount" ] && /etc/init.d/unblockmusic restart
(( log_size = "$(ls -l "${log_file}" | awk -F ' ' '{print $5}')" / "1024" ))
(( "${log_size}" >= "${log_max_size}" )) && echo "" > /tmp/unblockmusic.log
sleep 10m

View File

@ -24,6 +24,7 @@ function check_latest_version(){
else
echo -e "\nLocal version: $(cat /usr/share/UnblockNeteaseMusic/local_ver 2>/dev/null), cloud version: ${latest_ver}." >>/tmp/unblockmusic_update.log
echo -e "You're already using the latest version." >>/tmp/unblockmusic_update.log
[ "${luci_update}" == "n" ] && /etc/init.d/unblockmusic restart
exit 3
fi
fi
@ -47,14 +48,14 @@ function update_core(){
echo -e "Failed to download core." >>/tmp/unblockmusic_update.log
exit 1
else
[ "${luci_update}" == "y" ] && touch "/usr/share/unblockneteasemusic/update_successfully"
echo -e "${latest_ver}" > /usr/share/UnblockNeteaseMusic/local_ver
/etc/init.d/unblockmusic restart
cat /usr/share/UnblockNeteaseMusic/package-lock.json | grep version |awk -F ':' '{print $2}' | cut -c3-8 > /usr/share/UnblockNeteaseMusic/core_ver
fi
echo -e "Succeeded in updating core." >/tmp/unblockmusic_update.log
echo -e "Local version: $(cat /usr/share/UnblockNeteaseMusic/local_ver 2>/dev/null), cloud version: ${latest_ver}.\n" >>/tmp/unblockmusic_update.log
cat /usr/share/UnblockNeteaseMusic/package-lock.json | grep version |awk -F ':' '{print $2}' | cut -c3-8 > /usr/share/UnblockNeteaseMusic/core_ver
/etc/init.d/unblockmusic restart
}
function main(){
@ -62,4 +63,7 @@ function main(){
check_latest_version
}
luci_update="n"
[ "$1" == "luci_update" ] && luci_update="y"
main