1. 程式人生 > >Jenkins啟動專案後臺程序自動殺掉

Jenkins啟動專案後臺程序自動殺掉

set BUILD_ID=dontKillMe 


start *****.bat 

問題:

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 herehttp://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!


國外網友回答問題:


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.




shareimprove this answer
answered Oct 2 '09 at 14:30




Michael Donohue
10.2k42043
 
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 wiki.hudson-ci.org/display/HUDSON/Spawning+processes+from+build? – reef Oct 2 '09 at 14:34
 
Hudson bug reported hudson.dev.java.net/issues/show_bug.cgi?id=3105. – reef Oct 2 '09 at 14:55
 
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 Oct 2 '09 at 15:07
 
Setting BUILD_ID is not a workaround, it is the currently recommended solution. – Michael Donohue Oct 5 '09 at 14:52
 
This approach doesn't work with all applications, however. Weblogic 8.1, for example, bombed out big time with BUILD_ID=dontKillMe. – jcelgin Feb 10 '10 at 17:11
show 1 more comment