#!/usr/bin/env ruby require 'optparse' require 't2-web' # Set up and parse arguments opts = OptionParser.new do |opt| opt.banner = "Usage: t2-web [options] start|stop|restart" opt.separator("\nSupports the following options:") opt.on("-d", "--daemonize", "Run daemonized in the background") opt.on("-p", "--port PORT", "Use PORT (default: 3000)") opt.on("-s", "--servers NUM", "Number of servers to start") opt.on_tail("-v", "--version", "Show the version") do puts "Taverna 2 Web Interface Generator version: #{T2Web::VERSION}" exit end opt.on_tail("-h", "-?", "--help", "Show this message") do puts opt exit end end # parse options (currently only displaying and passing all to thin!) opts.parse! if ARGV.size == 0 puts opts exit end # TODO: call webapp via rack and ruby rather than from the prompt!! INSTALL_DIR = `gem environment gemdir`.chomp + "/gems/t2-web-#{T2Web::VERSION}/bin" # cd to proper dir and run thin $* for now success = `cd #{INSTALL_DIR} ; thin #{$*.join(' ')}` if success puts "Running: thin #{$*.join(' ')} !" else puts "Failed running: thin #{$*} !" end