Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start Tomcat remotely with Fabric

I've run an issue with Tomcat 7 and fabric. I'm able to stop tomcat remotely. Unfortunately, I'm not able to start it with python-fabric. It gives me an output and there's no sign of error but still tomcat is not starting up. This is my fabric command:

@task
def start_tomcat():
    sudo('/opt/tomcat/bin/startup.sh')

Ouput:

[bw.node1] Executing task 'start_tomcat'
Starting Tomcat
[bw.node1] run: echo $JAVA_HOME
[bw.node1] out: /usr/lib/jvm/java-1.6.0
[bw.node1] out: 

[bw.node1] sudo: ./startup.sh
[bw.node1] out: sudo password:
[bw.node1] out: Using CATALINA_BASE:   /opt/tomcat
[bw.node1] out: Using CATALINA_HOME:   /opt/tomcat
[bw.node1] out: Using CATALINA_TMPDIR: /opt/tomcat/temp
[bw.node1] out: Using JRE_HOME:        /usr/lib/jvm/java-1.6.0
[bw.node1] out: Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
[bw.node1] out: 


Done.
Disconnecting from bw.node1... done.

And still nothing is happening. I've also checked catalina.out and tomcat is not starting up.

like image 205
Sayat Satybald Avatar asked Dec 14 '22 22:12

Sayat Satybald


1 Answers

Finally, I was able to figure out how to startup tomcat remotely with fabric.

The issue was in background tasks as they will be killed when the command ends.

The solution is simple: just add "set -m;" prefix before command. The full fabric command should be:

sudo('set -m; /opt/tomcat/bin/startup.sh')

Source

like image 194
Sayat Satybald Avatar answered Dec 26 '22 05:12

Sayat Satybald