Class: Colloquy::Runner
- Inherits:
-
Object
- Object
- Colloquy::Runner
- Defined in:
- lib/colloquy/runner.rb
Class Method Summary collapse
-
.run!(argv) ⇒ Object
Much of this is borrowed verbatim from Goliath internals so we can use our own class structure.
Class Method Details
.run!(argv) ⇒ Object
Much of this is borrowed verbatim from Goliath internals so we can use our own class structure
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/colloquy/runner.rb', line 26 def run!(argv) = {} goliath_argv = [] option_parser = OptionParser.new do |opt| opt. = 'Usage: colloquy [options] /path/to/flow/root' opt.on('-a', '--address HOST', 'Hostname or IP address to bind to') do |host| goliath_argv << '-a' << host end opt.on('-p', '---port PORT', 'Port to run the server on') do |port| goliath_argv << '-p' << port end opt.on('-e', '---environment ENV', 'Rack environment to run the renderer') do |env| goliath_argv << '-e' << env [:environment] = env end opt.on('-P', '--pidfile PATH_TO_FILE', 'Location to write the PID file to') do |pid_file| goliath_argv << '-P' << pid_file end opt.on('-d', '--daemonize', 'Daemonize the server') do goliath_argv << '-d' end opt.on('-v', '--verbose', 'Turn on debug logging') do goliath_argv << '-v' [:verbose] = true end opt.on('-s', '--simulator', 'Run the flow simulator instead') do [:interactive] = true end opt.on( '-h', '--help', 'Display this screen' ) do puts opt exit! end end option_parser.parse!(argv) path_root = argv.pop unless path_root puts 'You have to provide a flow root directory. See colloquy --help' exit! end goliath_argv << '-l' << Pathname.new(path_root).realpath.join('log', 'server.log').to_s if [:interactive] simulator = Colloquy::Simulator.new(path_root: path_root, verbose: [:verbose]) simulator.run else klass = Colloquy::Server api = klass.new(path_root: path_root, verbose: [:verbose]) runner = Goliath::Runner.new(goliath_argv, api) runner.app = Goliath::Rack::Builder.build(klass, api) runner.load_plugins(klass.plugins) runner.run end end |