Ant Exec Spawn Jobs Broke Under Hudson?

A recent update of Hudson, a great continuous integration engine, has fixed one bug, only to introduce a new one. On February 19th, 2009, Hudson bug #2729 (an issue about Hudson not cleaning up run-away processes after the build is complete) was fixed by Hudson now killing off all processes created by the build task, including intentionally spawned daemons or tasks you wanted to keep alive.

If, like me, you use an Ant task to start your application server using an exec task with the spawn set to true at the end of a Hudson build, this means that when you upgrade Hudson, your application server will stop starting, but the rest of your build will continue to work as expected.

The issue is captured in Hudson bug #3105. The work around is to set the BUILD_ID environment variable to “dontKillMe” for the process you wish to not be killed. The Hudson bug mentions solving this through setting the BUILD_ID via a build parameter, however that requires that you enter or accept the default parameter each time you want to run the build. Instead I simply added the environment variable to my exec task, like this:

[fusion_builder_container hundred_percent=”yes” overflow=”visible”][fusion_builder_row][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][xml]






[/xml]

———-EDIT———-

You can now disable this process killing behavior globally by adding this to your JAVA_OPTS:

[/fusion_builder_column][fusion_builder_column type=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”no” center_content=”no” min_height=”none”][plain]
-Dhudson.util.ProcessTreeKiller.disable=true
[/plain]
[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]


Posted

in

by

Tags:

Comments

7 responses to “Ant Exec Spawn Jobs Broke Under Hudson?”

  1. Alex Avatar
    Alex

    Thanks. Spent about an hour troubleshooting this until I found this post.

    1. Devon Avatar

      Glad I could help! It took me a while to figure it out, so hopefully folks will find my page before they tear out their hair:)

  2. Suresh Avatar
    Suresh

    great find. I’ve a similar problem when I use shell script to start my tomcat server after building the application, as soon as the job is done my tomcat stopped (or was killed rather). After spending some time I finally concluded using ant exec task is the best way to go using spawn option and I’m glad I found your article before pulling my hair out…

  3. philippe Avatar
    philippe

    Thanks! You saved my day, I was stuck with that odd problem!

  4. C S Shyam Sundar Avatar
    C S Shyam Sundar

    Damn! This was a life saver. :)

  5. Raivo Avatar

    Thanks a lot! I would have never figured it out myself. I spent two hours debugging my server launch scripts (they worked very well with other CI tools!).

  6. […] Posted on March 10, 2009 by Devon […]

Leave a Reply

Your email address will not be published. Required fields are marked *

PHP Code Snippets Powered By : XYZScripts.com