For far too long we’ve been running our TeamCity build agents on Windows 2003 Server. This was, originally, driven by necessity. We were using Selenium, and out client cared only for a single browser: Internet Explorer. As time progressed we decided Selenium was costing us more than we received from it, so we dropped it. And so we ended up using Windows to build for historical reasons only. And, of course, inertia.

So, over the last day or two, I’ve been building up replacements. Our build box is actually a PowerEdge 1950, split into two machines with the aid of VMWare ESXi. So I hacked together a build agent on VMWare Fusion to use as a template, copied it onto ESX, and set it spinning.

This was the point I got a kick in the arse. We were using Ubuntu 8.10 64bit – and ESX didn’t like it one bit. So I dragged a LCD and keyboard up to the server room and had a nose in the BIOS – sure enough, Dell had left VT off. Bloody Dell. I took advantage of the visit to hack SSH on in ESXi and headed downstairs.

No luck. Same error.

An hour later I stumbled on the solution. The VM had paravirtualisation turned on. Paravirtualisation, apparently, only supports 32bit hosts. Off went paravirtualisation and on went the build server. Win!

So, victory, one less Windows server, and once more a severe wish that VMWare would produce Infratructure Client for either Linux or Mac OS X.

That wasn’t all I learnt of value, however. JetBrains are good enough to tell you how to start TeamCity automatically on Windows (via a server) and the Mac (via launchd) and complete omit Linux. So I went and found out about Upstart.

End solution: create the scripts below in /etc/event.d. They’ll run on startup/shutdown, and can also be started manually using:

sudo start [start|stop]-teamcity-buildagent

/etc/event.d/start-teamcity-buildagent

start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5

console output

script
	exec su -l buildagent -c '/opt/build-agent/bin/agent.sh start'
end script

/etc/event.d/stop-teamcity-buildagent

start on shutdown

console output
script
	exec su -l buildagent -c '/opt/build-agent/bin/agent.sh stop'
end script