Closed notenking closed 11 years ago
WD works like other Ruby frameworks, if when loading the user code, some code can't be evaluated, an exception is raised and the program exits with an explanation.
We "could" change that behavior and ignore the fact that your code didn't load and keep on running the app but now some endpoints wouldn't work without you potentially noticing. I don't think that would be wise to do that, but if you want to try it, you can monkey patch the app loader and change the code you mentioned to something like that:
Dir.glob(File.join(root_path, "api", "**", "*.rb")).each do |api|
begin
require api
rescue => e
puts "WD couldn't load #{api}, error: #{e.inspect}"
end
end
When I use wd-sinatra as one of my project.I find when one of api have problem,like grammer error or include file not exist. All of my apis can't work again.
I must fix the error first and then other apis can work again. this problem make me can't put this project in my production server.
I find the load code in app_loader.rb l:
Dir.glob(File.join(rootpath, "api", "*", "_.rb")).each do |api| require api end
when a api can't execute normally,It's will throw exception.
So I want to know why wd-sinatra do like this,How can i fix this problem?
thanks