views:

460

answers:

2

I have a Hudson job that launches a .bat script file that itself launches my Jonas application server and a couple of other tasks too.

The script is properly launched from Hudson on my slave, then my application server is started but at the moment my Hudson job ends the application server is killed. This is due to the fact that all the processes launched during this process share the same pipes (stdin/sdtout/stderr) as explained here http://wiki.hudson-ci.org/display/HUDSON/Spawning+processes+from+build.

As you already understood, this is really not what I want! Actually I have another Hudson job that is launched right after the one I described above to test my application. Thus, as my application server has been killed at the same moment the Hudson jobs ended, my tests cannot run at all...

So how can I solve this?

This problem is strictly linked to the fact that it is Hudson that launches the script, if I launch the same script from the command line the problem does not occur at all...

In the link given above they propose to use the "at" command which allows to schedule a task in Windows. I don't really want to use this solution as this implies modifications in my .bat script because I launch it from Hudson.

  • I suppose there is a way to say to my .bat file "Ok you are going to launch my application server BUT in an independent process". Do you guys know how to do this?
  • Maybe Hudson is able to solve this issue? Do you Hudson's guys know how?

Thanks in advance for you help!

+2  A: 

Try to launch your application server with the START command. This site gives some examples of the usage. I guess you have to do some experiments about the right parameters but your first try should be:

START "appServer" "[path to your application server]\applicationServer.exe"
Frank Bollack
In this specific context this solution is not sufficient as everything is linked to a bug in Hudson (see previous comment). But in a non-bugged context this seems to be the solution ;)Thanks!
reef
Let me repeat - there is no bug here, clearing the environment variable is the intended way of dealing with the problem. Issue 3105 is an enhancement request.
Michael Donohue
+2  A: 

The best practice here is to clear the environment variable BUILD_ID. When cleaning up after a build job, Hudson looks at the BUILD_ID environment variable in each process, to kill off any lingering processes. So by clearing that environment variable, Hudson will not kill the process.

Michael Donohue
Thanks for your input! I saw you are kind of a Hudson guru in your profile ;)Should I clear the BUILD_ID variable or should I set it to BUILD_ID=dontKillMe as I saw on the link http://wiki.hudson-ci.org/display/HUDSON/Spawning+processes+from+build?
reef
Hudson bug reported https://hudson.dev.java.net/issues/show_bug.cgi?id=3105.
reef
Setting BUILD_ID environment variable in Hudons to dontKillMe works fine, but as explained in the reported bug (link above) this is a workaround. I will post the solution once the bug fixed.Thanks!!
reef
Setting BUILD_ID is not a workaround, it is the currently recommended solution.
Michael Donohue
This approach doesn't work with all applications, however. Weblogic 8.1, for example, bombed out big time with BUILD_ID=dontKillMe.
jcelgin