Posts Tagged Tools

Spawning a Process from Hudson

It took a little while to figure this out, and hence documenting here ...

Need is to restart JBoss once the artifacts are deployed. I have two different jobs, one for building and deploying artifacts (EAR, in this case) and the other one to restart the server. Former invokes the latter as a part of its post-build actions.

I've setup a build step in Hudson that executes a shell script which essentially invokes stop and start operations on the server. The server stops fine, but when I start the server in the background, server process gets killed once the Hudson process is finished. I've tried multiple ways of achieving this -- tried a couple of JBoss Maven plugins and tried Ant route too suspecting if that was an issue with my Shell script. But the real problem lies with the way Hudson deals with the spawned processes. This behavior is consistent with their design according to Hudson docs.

The suggested workaround for Unix systems is to use something like daemonize. That didn't work for me. Daemonize works fine but the process is still being killed by the Hudson.  [Side note: daemonize is a neat tool, glad that I stumbled on it. Need it for some other purposes].

So how was this resolved? Searching the bug tracker, found the exact issue that I mentioned here. The solution/workaround mentioned there works like a charm. Here is what it says --

set the environment variable BUILD_ID to something like 'dontKillMe' in the
process that should stay alive.

Hudson looks for that environment variable when cleaning up stray processes.

SetEnv plugin is already installed on my Hudson server, and setting BUILD_ID variable value worked! May be that Hudson could provide an option on the admin UI for the user to indicate not to kill the intentionally spawned processes.

Tags: ,

Thoughtworks Technology Radar (April 2010)

Somehow I missed the release of second edition of Thoughtworks' technology radar [PDF]. As they did in the inaugural edition they evaluated various techniques, tools, platforms and languages and put them in four buckets -- hold, assess, trial and adopt.

I will jump to the biggest surprise (but something that's consistent with what I'm hearing these days) -- GWT is moved back from Assess to Hold status. I used to be a fan of the approach GWT took, mostly coming from my angst towards writing Javascript, and to develop client-side stuff using the language that I'm quite familiar with -- Java.  Although I haven't done enterprise stuff with GWT yet, what I heard was it's not as productive as I was earlier thinking about, and this technology radar points to some of the issues with the generation of Javascript in terms of productivity, troubleshoting, not being able to utilize powerful features of Javascript, and unit testing. I'm not giving up yet on GWT, but would certainly like to hear feedback from the folks who used it in production-grade applications with good success.

As far as languages are concerned -- they are excited about two languages that I'm having great fun with -- Scala and Clojure. I'm fairly convinced that the enterprises sooner than later would evaluate options of using these JVM-based languages than sticking with Java alone. Java as a language is not dead yet (in fact far from it and dead is a too harsh a word), but if the current trend continues in terms of these new breed of JVM languages (coupled with some good customer stories) that day may not be that far off. Other than that in the languages section -- HTML 5 is gaining traction, which is expected.

In the tools category -- Restfulie has got a mention. I think this is pretty significant in the world of REST-based development. Restfulie is an excellent tool to achieve Hypermedia constraint (HATEOAS) of REST, which helps significantly in loose coupling between clients and servers. They said it well -- "It [success of Restufulie] is an emperical proof that the web and the hypermedia can be used to orchestrate complex business activities".

Also in the tools category -- Subversion moves back into the Adopt section. It has to be that way all along, in my opinion. I like distributed version control systems (Git and Mercurial) a lot but Subversion still has a place in the enterprise. I second their opinion that it's a solid version control system suitable for most teams. New to enter the radar is Github, another success story, undoubtedly popularized Git along with their source code hosting and social networking abilities.

Tags: ,

Graphical Representation Using Graphviz – Part 1

If you believe in the proverb - a picture is worth thousand words, then you would love this one. A few bloggers recently posted how Grand and Graphviz can be used for generating graphical views of the ANT dependencies. After a bit of research into how Grand achieved the task, I was inspired to do a similar thing, albeit on a different set of XML files (not on ANT scripts).In this post I will go over how these tools work together, and in the next part I will go over the details of creating a DOT file and generating the graphs to your liking.Before getting into the details, a quick summary of these tools below:

Grand

"Grand is a tool to create visual representation of ant target dependencies. It differs from tools like VizantAntGraph by a totally different approach, relying on the Ant API rather than parsing directly the XML files. This enables Grand to provide some nifty features such as the support of the ant 1.6.x tasks like import or subant".

Grand has a GUI, I haven't used it as I wanted to invoke this from ANT (or from command line).

Graphviz

"Graphviz is open source graph visualization software. It has several main graph layout programs. See the gallery for some sample layouts. It also has web and interactive graphical interfaces, and auxiliary tools, libraries, and language bindings."

"The Graphviz layout programs take descriptions of graphs in a simple text language, and make diagrams in several useful formats such as images and SVG for web pages, Postscript for inclusion in PDF or other documents; or display in an interactive graph browser. (Graphviz also supports GXL, an XML dialect.)"

Graph of ANT dependencies

For the demonstration purpose I'm using Spring Framework's build.xml.

Some obvious steps:

  1. Download Grand JAR
  2. Download and install Graphviz

Not so obvious ones:

  1. Create a typedef in your ANT build file
    <typedef resource="net/ggtools/grand/antlib.xml" classpath="lib/grand-1.8.jar" />
  2. Write an ANT target
    <target name="SpringFramework-BuildDiagram">   <grand output="docs/spring-f
    ramework.dot" buildfile="spring-framework-build.xml">
    
       <exec executable="dot" dir="docs">       <arg line="-Tpdf -Gsize=11.69,8.27 -Grotate=90 -o spring-framework.pdf spring-framework.dot"/>   </exec></target>

This is a two step process as described in the above target:

  • First step is to generate the dot file (note: this has got no relation with MS Word's dot template). DOT is a plain text description language of graphs. Provide an output path and what build file you need a diagram for.
  • Using that dot file graphviz generates the output graphs. Graphviz supports a wide range of output options. The above targets invoke dot and provides output type as PDF, provides the paper size to print on, and -Grotate value indicates the output to be rotated 90 degrees for landscape mode.

Here is a jpg output for Spring framework's build file --

Grand supports filters to remove any targets from the graph that you are not interested in. For example, if you are not interested in test-related targets and in isolated nodes (nodes that have no connections) the following ANT target achieves that functionality --

<target name="SpringFramework-BuildDiagram">   <grand output="docs/spring-framework.dot" buildfile="spring-framework-build.xml">        <filter name="removenode" node="clover.tests"/>       <filter name="removenode" node="clean.compile"/>       <filter name="isolatednode"/>    </grand>

   <exec executable="dot" dir="docs">       <arg line="-Tpdf -Gsize=11.69,8.27 -Grotate=90 -o spring-framework.pdf spring-framework.dot" />   </exec></target>

Resulting Graph --

spring-framework

Tags: ,