Created
October 29, 2013 03:16
-
-
Save niw/7208705 to your computer and use it in GitHub Desktop.
Running rubygems server on localhost.
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
#!/usr/bin/env ruby | |
require 'webrick' | |
require 'rubygems' | |
require 'rubygems/gem_runner' | |
require 'rubygems/exceptions' | |
REPOSITORY_ROOT = File.expand_path("../", __FILE__) | |
# Update index | |
begin | |
Gem::GemRunner.new.run ["generate_index", "-d", REPOSITORY_ROOT] | |
rescue Gem::SystemExitException => e | |
exit e.exit_code | |
end | |
# Start HTTP server | |
WEBrick::HTTPServer.new( | |
:Port => 3000, | |
:BindAddress => '127.0.0.0', | |
:DocumentRoot => REPOSITORY_ROOT, | |
:MimeTypes => WEBrick::HTTPUtils::DefaultMimeTypes | |
).tap do |server| | |
trap('INT') do | |
server.shutdown | |
end | |
server.start | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment