开发者

Restarting tomcat service through java/servlet

i want to restart my tomcat through my java code/servlet. Is there any way to do s开发者_开发知识库o??? ON particular Exception,i want to restart my tomcat


No need to run any application. In my code i m just executing my BATCH file. Here is a code for the same:

Runtime.getRuntime().exec("cmd.exe /c start C:\restart_tomcat.bat");

And following is my 'restart_tomcat.bat' file contains

C:\WINDOWS\system32\net stop TomcatServiceName
C:\WINDOWS\system32\net start TomcatServiceName
exit


may be you should write an external program that will execute the scripts shutdown.sh/startup.sh (CATALINA_HOME/bin) and call it when an exception occurs


If you have the manager application installed you can use it to stop and start individual deployed applications. Note that you don't want to get an application to ask the manager to stop and then restart itself for obvious reasons. Instead you could have a proxy-manager app which will would accept requests to stop and then restart other apps. Your app would then make requests to the proxy-manager.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜