kemal/src/kemal.cr

23 lines
568 B
Crystal
Raw Normal View History

2014-06-11 23:41:02 +00:00
require "option_parser"
2015-10-23 19:48:30 +00:00
require "./kemal/*"
2014-06-11 23:41:02 +00:00
2014-07-30 22:17:53 +00:00
at_exit do
OptionParser.parse! do |opts|
opts.on("-p ", "--port ", "port") do |opt_port|
2015-10-23 18:33:26 +00:00
Kemal.config.port = opt_port.to_i
2014-07-30 22:17:53 +00:00
end
2015-11-16 21:55:02 +00:00
opts.on("-e ", "--environment ", "environment") do |env|
2015-11-18 20:45:49 +00:00
Kemal.config.env = env
2015-11-16 21:55:02 +00:00
end
2014-06-11 23:41:02 +00:00
end
2015-10-23 18:33:26 +00:00
config = Kemal.config
2015-11-16 21:55:02 +00:00
config.add_handler Kemal::Logger.new
2015-11-12 20:48:22 +00:00
config.add_handler Kemal::Handler::INSTANCE
config.add_handler HTTP::StaticFileHandler.new("./public")
2015-11-16 21:55:02 +00:00
2015-11-12 20:48:22 +00:00
server = HTTP::Server.new(config.port, config.handlers)
2014-07-30 22:17:53 +00:00
server.ssl = config.ssl
2014-06-11 23:41:02 +00:00
server.listen
end