How to connect to remote server and start/stop the Tomcat that's running on that particular server using Ant?
Asked Answered
N

1

3

The purpose is to:

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 
Newcastle answered 3/5, 2012 at 13:27 Comment(2)
When I want to do that, I use ssh -o StrictHostKeyChecking=no user@hostname /home/tomcat/bin/shutdown.sh; /home/tomcat/bin/startup.sh But I would love to see another technique to do that (ideally without requiring ssh)Mamiemamma
Hello Guillaume Polet- I was thinking of running start/stop ant command to start and stop tomcat, jboss etc. This is we can deploy let say one.war file to multiple servers with let say a single ant deploy-to-servers target.Newcastle
F
6

I believe Tomcat Documentation under Monitoring and Managing Tomcat offers some information on how to stop a given application, but not the server entirely:

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

If you have ssh access to the server, then you might like to consider the JSch library which you can use in combination with SSHExec Ant Task to start and stop your server:

<sshexec host="somehost"
    username="dude"
    password="yo"
    command="/etc/init.d/tomcat restart"/>
Feminine answered 3/5, 2012 at 13:44 Comment(3)
I looked at your links, but I could not see where it explains how Tomcat can be started and stopped. But I may have just missed it.Mamiemamma
@Guillaume Polet I think I may have missunderstood the question. The link I offered provides ways to start or stop a given application within Tomcat. I will correct my answer.Feminine
+1 for the sshexec + jsch notes. i like that a lot as routinely i get an out of memory error if i just use the deploy task. the deploy itself works ... i'm sure there's a tomcat jvm memory setting i need to tweak, but your option is a more than suitable alternate. nice!Bridget

© 2022 - 2024 — McMap. All rights reserved.