public
Description: A new revision of Fuzed, the Erlang-based frontend for web apps. Check out the mailing list at http://groups.google.com/group/fuzed
Clone URL: git://github.com/KirinDave/fuzed.git
support 500s for rails and introduce framework specific modules
mojombo (author)
Fri Jun 27 21:56:40 -0700 2008
commit  e1f91c9bda7a3ee3f23074c28551196e0194a5f5
tree    ce1ab13fa4a67925d9ac46c1d2d8d58b6ccef0ce
parent  b5ae846ccea12fd2b3c1a646449e9463c32c4e46
...
43
44
45
 
46
47
48
49
50
 
 
51
52
53
...
94
95
96
 
 
 
 
 
 
97
98
99
100
...
43
44
45
46
47
48
49
 
 
50
51
52
53
54
...
95
96
97
98
99
100
101
102
103
104
105
106
107
0
@@ -43,11 +43,12 @@ init([]) ->
0
       {ok, DocRoot} = application:get_env(docroot),
0
       SSL = ssl_config(),
0
       ResponderModule = figure_responder(),
0
+ FrameworkModule = figure_framework_module(),
0
       AppModSpecs = process_appmods(application:get_env(appmods)),
0
   
0
       case application:get_env(http_server) of
0
- {ok, mochiweb} -> mochiweb_frontend:start(IP, Port, DocRoot, SSL, ResponderModule, AppModSpecs);
0
- _ -> yaws_frontend:start(IP, Port, DocRoot, SSL, ResponderModule, AppModSpecs)
0
+ {ok, mochiweb} -> mochiweb_frontend:start(IP, Port, DocRoot, SSL, ResponderModule, FrameworkModule, AppModSpecs);
0
+ _ -> yaws_frontend:start(IP, Port, DocRoot, SSL, ResponderModule, FrameworkModule, AppModSpecs)
0
       end
0
   end,
0
   
0
@@ -94,6 +95,12 @@ figure_responder() ->
0
       Module;
0
     undefined -> frontend_responder
0
   end.
0
+
0
+figure_framework_module() ->
0
+ {ok, Framework} = application:get_env(framework),
0
+ FrameworkString = atom_to_list(Framework),
0
+ FrameworkModuleString = FrameworkString ++ "_framework",
0
+ list_to_atom(FrameworkModuleString).
0
       
0
 process_appmods(undefined) -> [];
0
 process_appmods({ok, V}) -> V.
0
\ No newline at end of file
...
2
3
4
5
 
6
7
8
 
9
10
11
...
2
3
4
 
5
6
7
 
8
9
10
11
0
@@ -2,10 +2,10 @@
0
 
0
 -module(mochiweb_frontend).
0
 -author("Abhay Kumar <abhay@opensynapse.net>").
0
--export([start/6]).
0
+-export([start/7]).
0
 -export([request_loop/4]).
0
 
0
-start(IP, Port, DocRoot, _SSL, ResponderModule, AppModSpecs) ->
0
+start(IP, Port, DocRoot, _SSL, ResponderModule, _FrameworkModule, AppModSpecs) ->
0
   ReqLoopFun = fun(Req) -> ?MODULE:request_loop(Req, DocRoot, ResponderModule, AppModSpecs) end,
0
   mochiweb_http:start([{name, ?MODULE}, {ip, IP}, {port, Port}, {loop, ReqLoopFun}]).
0
 
...
1
2
 
3
4
5
6
 
 
7
8
9
...
39
40
41
42
 
43
44
45
...
48
49
50
 
51
52
53
...
1
 
2
3
4
 
 
5
6
7
8
9
...
39
40
41
 
42
43
44
45
...
48
49
50
51
52
53
54
0
@@ -1,9 +1,9 @@
0
 -module(yaws_frontend).
0
--export([start/6, start/1]).
0
+-export([start/7, start/1]).
0
 -include("yaws.hrl").
0
 
0
-start(IP, Port, DocRoot, SSL, ResponderModule, AppModSpecs) ->
0
- {GC, SC} = yaws_global_configs(IP, Port, DocRoot, SSL, ResponderModule, AppModSpecs),
0
+start(IP, Port, DocRoot, SSL, ResponderModule, FrameworkModule, AppModSpecs) ->
0
+ {GC, SC} = yaws_global_configs(IP, Port, DocRoot, SSL, ResponderModule, FrameworkModule, AppModSpecs),
0
   application:set_env(yaws, embedded, true),
0
   application:start(yaws),
0
   yaws_api:setconf(GC, [[SC]]).
0
@@ -39,7 +39,7 @@ yaws_gc() ->
0
              },
0
   GC.
0
 
0
-yaws_global_configs(IP, Port, DocRoot, SSL, ResponderModule, AppModSpecs) ->
0
+yaws_global_configs(IP, Port, DocRoot, SSL, ResponderModule, FrameworkModule, AppModSpecs) ->
0
   {AppModModules, Opaques} = prepare_appmod_data(AppModSpecs),
0
   % io:format("DEBUG:~n~p~n---~n~p~n", [AppModModules, Opaques]),
0
   GC = yaws_gc(),
0
@@ -48,6 +48,7 @@ yaws_global_configs(IP, Port, DocRoot, SSL, ResponderModule, AppModSpecs) ->
0
               listen = IP,
0
               docroot = DocRoot,
0
               errormod_404 = ResponderModule,
0
+ errormod_crash = FrameworkModule,
0
               appmods = AppModModules,
0
               opaque = Opaques},
0
   case SSL of
...
52
53
54
 
 
 
 
 
55
56
57
...
101
102
103
 
104
105
106
...
165
166
167
 
168
169
170
...
52
53
54
55
56
57
58
59
60
61
62
...
106
107
108
109
110
111
112
...
171
172
173
174
175
176
177
0
@@ -52,6 +52,11 @@ OptionParser.new do |opts|
0
     options[:http_server] = server
0
   end
0
   
0
+ opts.on("--framework FRAMEWORK", "Framework to use. Choices are: rails") do |framework|
0
+ $stderr.puts "Unknown framework type. Using rails." unless %w[framework].include?(framework)
0
+ options[:framework] = framework
0
+ end
0
+
0
   opts.on("--conf CONF", "Configuration file") do |conf|
0
     options[:conf] = conf
0
   end
0
@@ -101,6 +106,7 @@ OptionParser.new do |opts|
0
 end.parse!
0
 
0
 http_server = options[:http_server] || DEFAULT_HTTP_SERVER
0
+framework = options[:framework] || 'rails'
0
 detached = options[:detached] ? '-detached' : ''
0
 master = options[:master_name] || DEFAULT_MASTER_NODE
0
 nodename = options[:name] || DEFAULT_NODE_NAME
0
@@ -165,6 +171,7 @@ else
0
                -fuzed_frontend http_server '#{http_server}' \
0
                -fuzed_frontend details #{details} \
0
                -fuzed_frontend docroot '"#{docroot}"' \
0
+ -fuzed_frontend framework #{framework} \
0
                #{ssl_details} \
0
                -fuzed_frontend port #{port} \
0
                #{fuzed_appspecs} \
...
109
110
111
 
112
113
114
...
109
110
111
112
113
114
115
0
@@ -109,6 +109,7 @@ cmd = %Q{erl -boot start_sasl \
0
              -fuzed_node master "'#{master}'" \
0
              -fuzed_node spec '#{spec}' \
0
              -fuzed_node num_nodes #{num_nodes} \
0
+ -fuzed_node framework 'rails' \
0
              #{inet} \
0
              -config '#{FUZED_ROOT}/conf/fuzed_base' \
0
              -run fuzed_node start}.squeeze(' ')
...
41
42
43
 
 
 
 
44
45
46
...
41
42
43
44
45
46
47
48
49
50
0
@@ -41,6 +41,10 @@ class MainController < ApplicationController
0
     render :text => request.remote_ip.to_s
0
   end
0
   
0
+ def fail
0
+ raise "failboat"
0
+ end
0
+
0
   protected
0
 
0
   def authenticate

Comments

    No one has commented yet.