#!/usr/bin/env ruby require 'optparse' require 'stackprof-webnav' require 'rack' options = { :port => 9292 } parser = OptionParser.new(ARGV) do |o| o.banner = "Usage: stackprof-webnav [-f localfile.dump]|[-d directory]|[-p NUMBER]" o.on('-f [LOCALFILE]', 'Local file path to dump') {|filepath| options[:filepath] = filepath } o.on('-d [DIRECTORY]', 'path to a directory with dumps') {|directory| options[:directory] = directory} o.on('-p [PORT]', 'Server port') {|port| options[:port] = port } end parser.parse! server = StackProf::Webnav::Server server.cmd_options = options Rack::Handler.pick(['thin', 'webrick']).run server.new, :Port => options[:port]