Class: Monorail::MonorailServer

Inherits:
Object
  • Object
show all
Defined in:
lib/monorail/server.rb

Instance Method Summary collapse

Constructor Details

#initializeMonorailServer

Returns a new instance of MonorailServer.



41
42
# File 'lib/monorail/server.rb', line 41

def initialize
end

Instance Method Details

#runObject



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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/monorail/server.rb', line 45

def run
  options = OpenStruct.new
  options.host = "127.0.0.1"
  options.port = 8900
  options.ssl = false
  options.daemon = false
  options.environment = :monorail
  options.directory = "."

  opts = OptionParser.new {|opts|

    opts.separator ""
    opts.separator "Options summary:"

    opts.on("-a", "--addr IP-address",
      "Requires the host IP address to listen on",
      "    default: 127.0.0.1") {|addr|
        options.host = addr
    }

    opts.on("-p", "--port TCP port",
      "Requires the TCP port to listen on",
      "    default: 8900") {|port|
        options.port = port.to_i
    }

    opts.on("-s", "--[no-]ssl", "Require SSL (HTTPS)",
      "    default: false") {|ssl|
        options.ssl = ssl
    }

    #opts.on("-d", "--[no-]daemon", "Run in the background",
    #  "    default: false") {|d|
    #    options.daemon = d
    #}

    opts.on("-e", "--env ENVIRONMENT", "execution environment",
          "    choices: monorail, rails, static",
          "    default: monorail") {|e|
      options.environment = e.to_s.downcase.intern
    }

    opts.on("-d", "--dir DIRECTORY", "directory where the application is located",
          "    default: the current directory") {|d|
      options.directory = d.to_s
    }


    # Options summary
    opts.on_tail("-h", "--help", "Show this message") {
      puts opts
      exit
    }

    # Version
    opts.on_tail("--version", "Show version") {
      puts Version
      exit
    }


  }

  opts.parse!(ARGV)
  Monorail.new( options ).run

end