Posted By

ishikawa on 08/01/06


Tagged

server ruby


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Simple webrick server


 / Published in: Ruby
 

Simple HTTP server daemon (webrick).

  1. #!/usr/bin/ruby
  2.  
  3. require 'webrick'
  4. include WEBrick
  5.  
  6. def start_webrick(config = {})
  7. config.update(:Port => 5001)
  8. server = HTTPServer.new(config)
  9.  
  10. yield server if block_given?
  11. ['INT', 'TERM'].each do |signal|
  12. trap(signal) { server.shutdown }
  13. end
  14.  
  15. server.start
  16. end
  17.  
  18. start_webrick(:DocumentRoot => 'path-to-document-root',
  19. :ServerType => Daemon)

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jtroyan on May 19, 2010

sdfsdfsdfsd zfsdf

Posted By: jtroyan on May 19, 2010

sdfsdfsdfsd zfsdf

Posted By: cleofas on February 11, 2011

es bueno

Posted By: muneswaraduggirala on July 8, 2011

lsdlfdsf kdfdf

You need to login to post a comment.