Capistrano and Glassfish (now with Gem!)
As I mentioned a while ago over here, Glassfish can be managed without a problem from Capistrano. In that post, I also mentioned that Gem wouldn't work, because it couldn't daemonize itself yet.
Well, gem 0.9.3 includes daemonization support, and I've finally gotten some time to go back and write capistrano recipes for gem. Just as before, I'll be working off of a standard deploy.rb, but you'll need to make a few changes. First, stick these into the top of your script.
set :context_root, "/" set :jruby_location, "/home/jacob/jruby/" set :gf_port, "3000" set :environment, "production" set :jruby_runtimes, "1" set :jruby_min_runtimes, "1" set :jruby_max_runtimes, "2" |
Of those, only jruby_location is really needed, since the rest of them can be persisted in the glassfish gem yml config file. For a capistrano deployment you might as well set them here, though, so that all the options you are using are in a central location. Now, we need some actual commands:
namespace :gem do desc "Start Glassfish Gem from a shutdown state" task :cold do start end desc "Stop a server running Glassfish Gem" task :stop do run "kill -INT $(cat #{current_path}/capistrano-#{application})"
end desc "Starts a server running Glassfish Gem" task :start do run "#{jruby_location}bin/jruby -S glassfish --contextroot #{context_root} --port #{gf_port} --environment #{environment} --runtimes #{jruby_runtimes} --runtimes-min #{jruby_min_runtimes} --runtimes-max #{jruby_max_runtimes} -P #{current_path}/capistrano-#{application} --daemon #{release_path}"
end desc "Restarts a server running Glassfish Gem" task :restart do stop start end end |
Jacob,
Your other post uses the "deploy" namespace rather than the "gem" namespace - you might want to do that here too.
Ikai
Posted by Ikai Lan on April 01, 2009 at 05:25 PM PDT #
Great post. Very helpful. Thanks a lot.
Posted by David Beckwith on July 20, 2009 at 03:02 AM PDT #