Managing Tomcat with Chef (or at least trying to)

It turns out running Tomcat's start hides a bit of a gotcha: it doesn't always work with non-interactive shells. Specifically, it doesn't properly detach from the parent process and is killed when the remote session ends. For example, running knife-ssh "search query" "/path/to/tomcat/bin/ start" will cause Tomcat to start and then be immediately killed when the SSH session ends. If you start Tomcat via a Chef recipe and you're executing chef-client remotely via knife-ssh, your results will vary depending on how you execute the command. Using Chef's execute resource seems to work okay, but running a System call inside a ruby_block resource does not. So running chef-client through an interactive SSH session will work, but launching chef-client via knife ssh will cause the Tomcat process to be killed with no output to the log files.

As a workaround, launch via nohup: nohup /path/to/tomcat/bin/ start