Created
February 25, 2021 08:22
-
-
Save kinnalru/9c99ccf1060bed03e790761f3cd9f37e to your computer and use it in GitHub Desktop.
StartWebrickDocker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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