views:

124

answers:

1

As part of deployment of an application, I use Hudson to launch the built application on a remote release server. This is done by specifying a post build step using the "Execute shell" option.

I copy a deploy.sh script to the remote server and execute it via ssh, e.g.

scp /opt/myapp/deploy.sh myapp@myserver:/export/home/myapp/scripts/
ssh myapp@myserver "/export/home/myapp/scripts/deploy.sh"

The deploy.sh script launches a java application and then writes the PID to file, e.g.

java -jar /opt/myapp/myapp.jar > /opt/myapp/myapp.log &
echo $! > /var/run/myapp/myapp.pid

(Note: there are steps prior to this - e.g. unzipping a deployment package)

The strange thing is that, when I run the Hudson build, it seems to hang following executing, via SSH, the deploy.sh script. The java app launches and the correct PID is written to file. It seems that Hudson has not been able to detect that the script has completed. If I take out the Java launch step, it completes no problem.

Can anybody see what I've missed?

Thanks,

Andrew

+1  A: 

When launching background processes from an SSH session, you need to redirect all of the background process's I/O. Otherwise, SSH will hang on exit.

So change your java launch command to:

java -jar /opt/myapp/myapp.jar > /opt/myapp/myapp.log 2>&1 < /dev/null &
pra
This worked a treat - thanks.
drewzilla