如何使用Ant连接到远程服务器并启动/停止在该特定服务器上运行的Tomcat?

时间:2012-05-03 13:27:36

标签: java xml ant jmx cargo

目的是:

1: connect to a remote server maybe via host: ip , port: 8181
2: stop Tomcat that's running on that server 
3: deploy a .war file 
4: restart tomcat 

1 个答案:

答案 0 :(得分:6)

我相信Tomcat Documentation下的Monitoring and Managing Tomcat提供了有关如何停止给定应用程序的一些信息,但不完全是服务器:

<jmx:invoke
    name="Catalina:type=Manager,path=/servlets-examples,host=localhost" 
    operation="stop"/>

如果您拥有对服务器的ssh访问权限,那么您可能会考虑将JSch librarySSHExec Ant Task结合使用来启动和停止服务器:

<sshexec host="somehost"
    username="dude"
    password="yo"
    command="/etc/init.d/tomcat restart"/>