require "http/server" server = HTTP::Server.new do |context| puts "received http request: #{Time.now}\n" sleep 60.seconds context.response.content_type = "text/plain" context.response.print "The time is #{Time.now}\n" end Signal::INT.trap do puts "received signal: #{Time.now}\n" server.close end server.bind_tcp "0.0.0.0", 8080, true puts "Listening on http://0.0.0.0:8080" server.listen puts "exit: #{Time.now}\n"