Sha256: 7e839fe3f3e68f631939add89cb9e90caf00809113e26954a08c1ed6c446cbfe

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby
# -*- mode: enh-ruby -*-

require 'store/digest'
require 'store/digest/http'
require 'commander'
require 'rack'


HOST    = '0.0.0.0'
PORT    = 10101
MAPSIZE = 2**30

Commander.configure do
  program :name,        File.basename($0)
  program :version,     Store::Digest::HTTP::VERSION
  program :description, 'Command-line starter for Store::Digest::HTTP'

  command :serve do |c|
    c.option '-d', '--dir DIR', 'The root directory of the store'
    c.option '-m', '--mapsize BYTES', 'The memory map size of the store'
    c.option '-h', '--host NAME', "Specify host"
    c.option '-p', '--port NUMBER', "Specify TCP port (default #{PORT})"
    c.option '-z', '--detach', 'Detach and daemonize the process'
    c.option '-F', '--fastcgi', 'Run as FastCGI rather than standalone'

    c.action do |args, opts|
      opts.default :host => HOST, :port => PORT, :mapsize => MAPSIZE

      raise Commander::Runner::CommandError.new 'No root directory' unless
        opts.dir

      store = Store::Digest.new dir: opts.dir, mapsize: opts.mapsize

      Rack::Server.start({
        app:         Store::Digest::HTTP.new(store),
        server:      opts.fastcgi ? 'fastcgi' : 'webrick',
        environment: 'none',
        daemonize:   opts.detach,
        Host:        opts.host,
        Port:        opts.port,
      })
    end
  end

  default_command :serve

  run!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
store-digest-http-0.1.0 exe/store-digest