Skip to content
This repository was archived by the owner on Dec 25, 2020. It is now read-only.
This repository was archived by the owner on Dec 25, 2020. It is now read-only.

Reload changed sources #1

@nightscape

Description

@nightscape

Hi Michael,

I'm trying to develop an application for which Wee seems very well suited.
One thing that slows down development quite a lot is that when I change the Ruby code of a component, the component does not get reloaded.
Rails and Ramaze both do this and its very useful!
To achieve this, you can reuse Ramaze's source reloader which is a Rack app:
require 'rack/handler/webrick'
require 'ramaze'

app = Rack::Builder.app do
  use Ramaze::Reloader
  Wee::JQuery.install('/jquery', self)
  map '/' do
    run Wee::Application.new {
      Wee::Session.new(HelloWorld.new)
    }
  end
end
Rack::Handler::WEBrick.run(app, :Port => 2000)

This correctly reloads the changed files.
The only problem is that the server is not shut down before the reload and blocking the port.
You can redefine some methods in Ramaze::Reloader::Hooks in order to do this,
but I'm not proficient enough in Rack, WEBrick and Wee to do this.
Anyway, here is what I tried:
$server = nil
Rack::Handler::WEBrick.run(app, :Port => 2000) {|srvr| $server = srvr }
Ramaze::Reloader::Hooks.class_eval do
def before_cycle
$server.shutdown
end
end

It would be great if you could add the missing puzzle peaces.

Thanks a lot!
Martin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions