Skip to content

Instantly share code, notes, and snippets.

@kinnalru
Created February 25, 2021 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinnalru/9c99ccf1060bed03e790761f3cd9f37e to your computer and use it in GitHub Desktop.
Save kinnalru/9c99ccf1060bed03e790761f3cd9f37e to your computer and use it in GitHub Desktop.
StartWebrickDocker
class StartWebrickDocker < Base
def start
cmd = "
require \"webrick\"
require \"logger\"
WEBrick::HTTPServer.new(Host: \"0.0.0.0\", Port: 80, MaxClients: 3000, ShutdownSocketWithoutClose: true, Logger: Logger.new(IO::NULL), AccessLog: []).start"
exec "docker run --rm -p #{@port}:80 --name http ruby:2.5-alpine /usr/local/bin/ruby -e '#{cmd}'"
end
def stop(_pid)
system("docker rm -f http &> /dev/null")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment