while ! systemctl status tomcat --no-pager | grep -q 'Deployment of.*demo.war.* has finished'; do \
echo -ne "."; sleep 1; \
done && echo "War deployed"
具有 catalina.sh 如果 catalina.sh run 使用来自apache的包(使用 catalina.sh start (不起作用)
while read -r line; do
if echo "$line" | grep -q 'Deployment of.*[/]demo.war.* has finished' ; then
echo "*****$line"
# do some stuff with your app
break
else
echo "---- $line"
fi
done < <(./bin/catalina.sh run 2>&1 &) && echo "War deployed"
# start tomcat ----------^
# with console output but in background
./bin/catalina.sh stop
监控日志文件 可能需要对日志文件的权限。
log='/var/log/tomcat/catalina.2021-07-05.log'
msg='Deployment of.*[/]demo.war.* has finished'
while read -r line; do
if echo "$line" | grep -q "$msg" ; then
echo "*****$line"
# do some stuff with your app
break
else
echo "---- $line"
fi
done < <(tail -n 1 -f "$log")
echo "War deployed"
sleep 5 # get a chance to see the previous message :-p
如果从eclipse启动tomcat
log='/home/lmc/workspace/.metadata/.plugins/org.eclipse.wst.server.core/logs/catalina.out'
msg='Deployment of deployment descriptor .*demo.xml. has finished'
# same code as above
和tomcat经理 配置tomcat管理器后:
until ! curl -u userblah:s3cr3t --silent "http://localhost:8080/manager/text/list" | grep '^[/]demo:running'; do
echo "Deploying 'demo' app"
sleep 1
done
1条答案
按热度按时间5anewei61#
具有
systemd
如果您使用systemctl启动tomcat,或者catalina.sh使用systemctl,则可以执行类似的操作。改变demo.war
根据您的战争名称,调整睡眠时间以显示尽可能多的睡眠时间.
(点)根据需要。如果部署需要30秒,它将显示30个点。具有
catalina.sh
如果catalina.sh run
使用来自apache的包(使用catalina.sh start
(不起作用)监控日志文件
可能需要对日志文件的权限。
如果从eclipse启动tomcat
和tomcat经理
配置tomcat管理器后:
带Spring Boot执行器
如果您的spring boot应用程序使用spring boot actuator并配置为
可通过以下方式对其进行监控: