Sha256: e697bcec17d259d1f08d88b42b7f8b2e1c6eda539f9b073a87b7a9428a8764a9

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../lib/hudson'
require 'un'
require 'optparse'


options = {
  :port => 3001,
  :control => 3002,
  :home => File.join(ENV['HOME'], '.hudson')
}
args = ARGV.dup

opts = OptionParser.new do |opts|
  opts.banner = "Usage: hudson [options] [HUDSON_HOME]"

  opts.on("-d", "--daemon", "fork into background and run as daemon") do
    options[:daemon] = true
  end

  opts.on("-p", "--port [3001]", "run hudson on specified port ") do |port|
    options[:port] = port
  end
  
  opts.on("-c", "--control-port [3002]", Integer, "set the shutdown/control port") do |port|
    options[:control] = cport
  end
  
  opts.on_tail("-k", "--kill", "send shutdown signal to control port") do
    require 'socket'
    TCPSocket.open("localhost", options[:control]) do |sock|
      sock.write("0")
    end
    exit
  end
  
  opts.on_tail("-v", "--version", "show version information") do
    puts "#{Hudson::VERSION} (Hudson Server #{Hudson::HUDSON_VERSION})"
    exit
  end
  opts.on_tail("-h", "--help") do
    puts opts
    exit
  end
  
end
opts.parse!(args)
dir = args.shift || options[:home]
FileUtils.mkdir_p dir
FileUtils.cp_r Hudson::PLUGINS, dir
ENV['HUDSON_HOME'] = dir
cmd = ["java", "-jar", Hudson::WAR]
cmd << "--httpPort=#{options[:port]}"
cmd << "--controlPort=#{options[:control]}"
cmd << "--daemon" if options[:daemon]
puts cmd.join(" ")
exec(*cmd)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hudson-0.2.4 bin/hudson