Wednesday, January 27, 2010

Knowing your faults

Knowing your faults is great advice. It's important to know where your own flaws lie, so that you can find ways to work around them. If you aren't aware of your flaws, you can wind up making some serious mistakes, like letting your emotions make your decisions for you.

I think the same can be said of software. It's important as an engineer to know where your software is weak. Every project I've ever been on has had at least ten things that "could be improved" if we had more time/money. Knowing this list is one thing, tracking it and adapting for it is another.

When designing software, it's important to make sure that the weaknesses aren't critical to the success of your business, however sometimes this is inevitable (or it was designed by someone else ;) ). Recognizing these flaws lets you mitigate them until you have a chance to remove them.

In real life, I have a set of close friends who are very honest with me. If I'm doing something stupid, they'll let me know. Imagine these friends as my profilers, loggers and monitors.

There was a recent blog post about Monitoring Driven Architecture. Finding and determining useful monitoring metrics can be the key differentiated between quickly solving architectural issues and shooting at the wall hoping you hit your own zombie-infested hand.

In the future, I will not start a new project without identifying weak areas and monitoring points. These things need to be monitored as soon as possible. Also, only real deployments can truly tell you which metrics are useful, so make sure you update your monitoring as time goes on.



To my readers who still subscribe even though I've been really lame about making useful posts recently:

I normally don't write these rambling though-stream posts, so send me some feedback. If you'd rather like more technical blogs, I'm working on a few (The "Leaky" Monad should hopefully be done soon ;) ).

Wednesday, January 20, 2010

Hudson Slave agent startup script

Last night, I got really annoyed at our hudson build slaves not automatically starting on our build nodes. I found a few init.d scripts online, and I pieced this one together with some additional functionality.

Still needs a bit more features, specifically:
  • Ability to run as hudson user or root user
  • Ability to change hudson port
  • Ability to have different Credentials

Anyway, I hope others find this helpful. It's meant to be run on a hudson build node to automatically connect to hudson at startup.

#!/bin/bash
#
# Init file for hudson server daemon
#
# chkconfig: 2345 65 15
# description: Hudson slave

. /etc/rc.d/init.d/functions


RETVAL=0
NODE_NAME="centos-executor"
HUDSON_HOST=1.2.3.4
USER=hudson

pid_of_hudson() {
   ps auxwww | grep java | grep hudson | grep -v grep | awk '{ print $2 }'
}

start() {
        if [ ! -e /var/log/hudson ]; then
  touch /var/log/hudson
  chown $USER /var/log/hudson
 fi
        echo -n $"Starting hudson: "
        COMMAND="java -jar /opt/hudson/slave.jar -jnlpUrl http://${HUDSON_HOST}/hudson/computer/${NODE_NAME}/slave-agent.jnlp 2>/var/log/hudson.err >/var/log/hudson"
        su ${USER} -c "$COMMAND" &
        sleep 1
        pid_of_hudson > /dev/null
        RETVAL=$?
        [ $RETVAL = 0 ] && success || failure
        echo
}

stop() {
        echo -n "Stopping hudson slave: "
        pid=`pid_of_hudson`
        [ -n "$pid" ] && kill $pid
        RETVAL=$?
        cnt=10
        while [ $RETVAL = 0 -a $cnt -gt 0 ] &&
                { pid_of_hudson > /dev/null ; } ; do
                        sleep 1
                ((cnt--))
        done

        [ $RETVAL = 0 ] && success || failure
        echo
}


status() {
        pid=`pid_of_hudson`
        if [ -n "$pid" ]; then
                echo "hudson (pid $pid) is running..."
                return 0
        fi
        echo "hudson is stopped"
        return 3
}


#Switch on called
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 (start|stop|restart|status}"
        exit 1
esac

exit $RETVAL

Wednesday, January 13, 2010

Too Busy

I've been crazy busy between work and writing a book. I have been writing a few blogs for the company, the first of which is complete, if you'd like to view it.


You can also see advertisements for my upcoming book (name misspelled, yay) on Manning's under contract page.