Sha256: 06dfcf9d70c8ccbd88d117298e860e055432c51e94fb3ba0ff86c2864285e682
Contents?: true
Size: 2 KB
Versions: 1
Compression:
Stored size: 2 KB
Contents
#!/usr/bin/env ruby # This software code is made available "AS IS" without warranties of any # kind. You may copy, display, modify and redistribute the software # code either by itself or as incorporated into your code; provided that # you do not remove any proprietary notices. Your use of this software # code is at your own risk and you waive any claim against the author # with respect to your use of this software code. # (c) 2007 Static-CMS require 'optparse' require 'fileutils' require 'Scms' require "scms/version" require 'webrick' require 'launchy' puts "Working dir: #{Dir::pwd}" options = {} optparse = OptionParser.new do|opts| # Set a banner, displayed at the top of the help screen. opts.banner = "Usage: scms-server [options]" options[:dir] = Dir::pwd opts.on( '-d', '--dir DIR', 'Document Root of http server [default = current working dir]' ) do|d| options[:dir] = d end # options[:host] = "localhost" # opts.on( '-h', '--host HOST', 'http host for http server [default = localhost]' ) do|h| # options[:host] = h # end options[:port] = 8008 opts.on( '-p', '--port PORT', 'port for http server [default = 8008]' ) do|p| options[:port] = p end options[:version] = false opts.on( '-v', '--version', 'Output scms version' ) do puts "Version: #{Scms::VERSION}" exit end # This displays the help screen, all programs are assumed to have this option. opts.on( '-h', '--help', 'Display this help screen' ) do puts opts exit end end optparse.parse! puts "Doc root: #{options[:dir]}" include WEBrick port = options[:port] puts "Starting server: http://#{Socket.gethostname}:#{port}" #:BindAddress server = HTTPServer.new(:Port=>port,:DocumentRoot=>options[:dir]) trap("INT"){ server.shutdown } uri = "http://localhost:#{port}" Launchy.open( uri ) do |exception| puts "Attempted to open #{uri} and failed because #{exception}" end begin server.start ensure server.shutdown end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scms-2.1.7 | bin/scms-server |