Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## # Task is an easy Mongrel controller. Intended as an easy and standard Mongrel wrapper for Ops and development. # Capistrano will not call this directly. namespace :util do namespace :mongrel_init do task :setup => :methods do |task| ## # Constants. APPLICATION_BASE_DIR = FileUtils.pwd APPLICATION_DIR_NAME = File.basename(FileUtils.pwd) APPLICATION_NAME = String.new if APPLICATION_DIR_NAME.match(/^\d+$/) if File.exists?("#{RAILS_ROOT}/config/deploy.rb") File.open("#{RAILS_ROOT}/config/deploy.rb", 'r') do |f| until f.eof do line = f.readline.chomp APPLICATION_NAME = line.split[2].gsub(/\"/, '') if line =~ /:application,/ end end end else APPLICATION_NAME = APPLICATION_DIR_NAME end ## # Do not run as root. raise("FATAL: Task (#{task.application.top_level_tasks}) should _not_ run as root!") if Process.uid == 0 end task :methods do def run_command(*args) cmd = args.join(" ") status = system(cmd) check_exit_status(status, cmd) end def check_exit_status(status, cmd) unless (status and ($?.exitstatus == 0)) then raise("FATAL: Problem executing (#{cmd})!") end end end desc "Name of application." task :name => :setup do puts APPLICATION_NAME end desc "Start Mongrel Cluster on the app." task :start => :setup do mongrel_clean = true run_command(MONGREL_RAILS_COMMAND, 'cluster::start', '-C', MONGREL_CONFIG_FILE) end desc "Restart Mongrel Cluster on the app." task :stop => :setup do run_command(MONGREL_RAILS_COMMAND, 'cluster::stop', '-C', MONGREL_CONFIG_FILE) end desc "Restart Mongrel Cluster on the app." task :restart => :setup do run_command(MONGREL_RAILS_COMMAND, 'cluster::restart', '-C', MONGREL_CONFIG_FILE) end end end
This paste will be private.
From the Design Piracy series on my blog: