Monday, December 17, 2007

Rake 'ing in the Tomcats

So I needed to have a quick way to start/stop/restart/tail -f logs for two different Apache Tomcat instances, Rake is a great tool for this.

I wrote the following very quickly, sure there may be other "frameworks" out there to do this, but I didn't download anything, just wrote it and off I go. (no xml, sorry Ant)

[sourcecode language="ruby"]
# home directory for all this stuff
HOME = '/path/to/my/tomcats'
# defining our servers and their locations
SERVERS = {
:one => "#{HOME}/tomcat_one/",
:two => "#{HOME}/tomcat_two/"
}

# sure there is a better way than this.?.?.
task :default do
puts "\nThe following are the tasks you may choose from:\n"
app = Rake.application
app.do_option('--tasks', ARGV.shift)
app.display_tasks_and_comments()
end

SERVERS.each do |name, dir|
namespace "#{name}" do
desc "start the #{name} server instance"
task :start do
Dir.chdir(dir)
puts `./bin/startup.sh`
end

desc "stop the #{name} server instance"
task :stop do
Dir.chdir(dir)
puts `./bin/shutdown.sh`
end

desc "tail the #{name} server log"
task :tail do
system("tail -f #{dir}/logs/catalina.out")
end
end
end

def server_names
SERVERS.keys.join(', ')
end

[:start, :stop].each do |action|
desc "#{action} servers (#{server_names()})"
task "#{action}" do
SERVERS.keys.each do |key|
task("#{key}:#{action}").invoke
end
end
end

desc "restart servers (#{server_names()})"
task :restart do
task(:stop).invoke
task(:start).invoke
end
[/sourcecode]

1 comment:

ckcnmmrcpq said...

They will require CAD software program and Computer Aided Manufacturing CAM software program that's extra capable as properly. In a mill, the cutter is placed in the spindle the place it rotates. The workpiece then moves past the cutter so that chips may be be} sliced off. The act of chopping a workpiece on a Teapots mill identified as} “Milling”. But the advent of first NC and then later CNC radically increased the quantity of automation that was possible when manufacturing. CNC Machining is the dominant methodology of machining supplies today, though manual machining continues to be quite frequent as properly for one-offs, restore, and prototyping work.