| Author |
Message |
< Yaws mailing list ~ Question about factoring of start_embedded/N |
| Guest |
Posted: Fri Dec 29, 2006 6:18 pm |
|
|
|
Guest
|
I've just started using start_embedded (mainly start_embedded/3 with
my own GL and SL), and have a question about some of the design
decisions behind that method. I've searched the archives and read
these threads:
http://sourceforge.net/mailarchive/message.php?msg_id=36726870
http://sourceforge.net/mailarchive/message.php?msg_id=37687506
but still have some questions.
What is the purpose of these lines (45-48 of yaws.erl:start_embedded/3
in my 1.66 distro):
GC = setup_gconf(GL, yaws_config:make_default_gconf(false, "")),
SC = setup_sconf(DocRoot, #sconf{}, SL),
yaws_config:add_yaws_soap_srv(GC),
yaws_config:add_yaws_auth(SL),
I was surprised to find them as I worked through getting my first
instance to come up, since I figured that if I passed in a GL and SL
then they would be used as-is. I'm also trying to understand the
inclusion of The soap/auth stuff as well, since in my case I'd rather
not follow those code paths by default.
As it is, I'm just using my own method which does what
start_embedded/3 does but without the lines above, since the lines
above make me a bit uncomfortable and I don't need them.
jon
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| tobbe |
Posted: Fri Dec 29, 2006 6:35 pm |
|
|
|
User
Joined: 19 Jan 2005
Posts: 274
Location: Stockholm, Sweden
|
Jonathan Gold skrev:
> I've just started using start_embedded (mainly start_embedded/3 with
> my own GL and SL), and have a question about some of the design
> decisions behind that method. I've searched the archives and read
> these threads:
>
> http://sourceforge.net/mailarchive/message.php?msg_id=36726870
> http://sourceforge.net/mailarchive/message.php?msg_id=37687506
>
> but still have some questions.
>
> What is the purpose of these lines (45-48 of yaws.erl:start_embedded/3
> in my 1.66 distro):
>
> GC = setup_gconf(GL, yaws_config:make_default_gconf(false, "")),
> SC = setup_sconf(DocRoot, #sconf{}, SL),
> yaws_config:add_yaws_soap_srv(GC),
> yaws_config:add_yaws_auth(SL),
I dont think you you need to be worried about the two lines above.
add_yaws_soap_srv/1 will only do things if: GC#gconf.enable_soap == true
and if so: start the yaws_soap_srv server.
add_yaws_auth/1 works in a similar way.
Cheers, Tobbe
>
> I was surprised to find them as I worked through getting my first
> instance to come up, since I figured that if I passed in a GL and SL
> then they would be used as-is. I'm also trying to understand the
> inclusion of The soap/auth stuff as well, since in my case I'd rather
> not follow those code paths by default.
>
> As it is, I'm just using my own method which does what
> start_embedded/3 does but without the lines above, since the lines
> above make me a bit uncomfortable and I don't need them.
>
> jon
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Sat Dec 30, 2006 12:42 am |
|
|
|
Guest
|
Tobbe --
Thank you very much for your reply. Below please find some simple code
and its shell output that demonstrates how to crash with
start_embedded/3, as a result of the auth code path.
--------------------------------------------------------------------------------
--------------------------- begin code snippet ---------------------------------
--------------------------------------------------------------------------------
-module( test ).
-compile( export_all ).
-include( "yaws_api.hrl" ).
-include( "yaws.hrl" ).
% Create exactly the gconf we want
yaws_gconf() ->
Yaws_home = "/tmp/yaws-sandbox",
GConf1 = yaws_config:make_default_gconf( false, "Test" ),
GConf1#gconf{
yaws_dir = Yaws_home,
logdir = "/tmp/logs",
tmpdir = "/tmp"
}.
% Create exactly the sconf we want
yaws_sconf() ->
SConf1 = yaws_config:make_default_sconf(),
SConf1#sconf{
port = 20000,
docroot = "/dev/null",
appmods = [ { "/a-custom-path", root } ]
}.
% Crashes on last line
make_yaws_start_embedded_crash() ->
GC = yaws_gconf(),
SC = yaws_sconf(),
yaws:start_embedded( "/dev/null", [ GC ], [ [ SC ] ] ).
% launches yaws successfully
skip_using_yaws_start_embedded() ->
application:load( yaws ),
application:set_env( yaws, embedded, true ),
application:start( yaws ),
GC = yaws_gconf(),
SC = yaws_sconf(),
yaws_api:setconf( GC, [ [ SC ] ] ).
--------------------------------------------------------------------------------
-------------------------- output from crashing code ---------------------------
--------------------------------------------------------------------------------
$ erl -pa -run test make_yaws_start_embedded_crash
Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0]
[kernel-poll:false]
Eshell V5.5.2 (abort with ^G)
1> {"init terminating in
do_boot",{{badrecord,sconf},[{yaws_config,setup_auth,1},{yaws_config,'-add_yaws_auth/1-fun-0-',1},{lists,map,2},{yaws,start_embedded,3},{init,start_it,1},{init,start_em,1}]}}
init terminating in do_boot ()
--------------------------------------------------------------------------------
-------------------------- output from working code ----------------------------
--------------------------------------------------------------------------------
$ erl -run test skip_using_yaws_start_embedded
Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0]
[kernel-poll:false]
Eshell V5.5.2 (abort with ^G)
1>
=INFO REPORT==== 29-Dec-2006::16:34:27 ===
Yaws: Listening to 127.0.0.1:20000 for servers
- http://localhost:20000 under /dev/null
--------------------------------------------------------------------------------
------------------------- back to the discussion... ----------------------------
--------------------------------------------------------------------------------
I hope what follows isn't too out of place, but I feel like it's more
resopnsible for me to press my point a little bit rather than silently shrug my
shoulders and just fork my own version of these methods at this point. In
particular, it seems that:
- The fact that the GC and SC records I pass in are not the ones ultimately
passed on to yaws_api:setconf is an underlying problem.
- This problem is compounded by the presence of the
yaws_config:add_yaws_auth code (which seems to ultimately result in the
crash)
- The method is doing too many things inside a single code path. Another
example of this seems to be the "DocRoot" parameter (required), which can
be redundant (as it is in my case) and without meaning in the case of
servers which don't serve actual documents from the file system.
I think it comes down to what is duscussed in Appendix B, Section 3.9 (p 221) of
Joe Armstrong's thesis. That section discusses the "principle of 'least
astonishment,'" and concludes with the sentence, "If you get astonished by what
a function does, either your function solves the wrong problem or it has a wrong
name." I'm thinking that's the problem here.
Can I suggest that we add a new method named something like
start_minimal_embedded (or a new signature for start_embedded that matches on
the atomic tag 'minimal') to change this? If that's met with a favorable
response, I'd enjoy having the chance to do it, get it reviewed by the Yaws
team, and submit it back to the project.
Thank you again for all of your work and attention.
jon
On Fri, Dec 29, 2006 at 07:35:01PM +0100, Torbjorn Tornkvist wrote:
> Jonathan Gold skrev:
> > I've just started using start_embedded (mainly start_embedded/3 with
> > my own GL and SL), and have a question about some of the design
> > decisions behind that method. I've searched the archives and read
> > these threads:
> >
> > http://sourceforge.net/mailarchive/message.php?msg_id=36726870
> > http://sourceforge.net/mailarchive/message.php?msg_id=37687506
> >
> > but still have some questions.
> >
> > What is the purpose of these lines (45-48 of yaws.erl:start_embedded/3
> > in my 1.66 distro):
> >
> > GC = setup_gconf(GL, yaws_config:make_default_gconf(false, "")),
> > SC = setup_sconf(DocRoot, #sconf{}, SL),
> > yaws_config:add_yaws_soap_srv(GC),
> > yaws_config:add_yaws_auth(SL),
>
> I dont think you you need to be worried about the two lines above.
> add_yaws_soap_srv/1 will only do things if: GC#gconf.enable_soap == true
> and if so: start the yaws_soap_srv server.
>
> add_yaws_auth/1 works in a similar way.
>
> Cheers, Tobbe
>
> >
> > I was surprised to find them as I worked through getting my first
> > instance to come up, since I figured that if I passed in a GL and SL
> > then they would be used as-is. I'm also trying to understand the
> > inclusion of The soap/auth stuff as well, since in my case I'd rather
> > not follow those code paths by default.
> >
> > As it is, I'm just using my own method which does what
> > start_embedded/3 does but without the lines above, since the lines
> > above make me a bit uncomfortable and I don't need them.
> >
> > jon
> >
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > opinions on IT & business topics through brief surveys - and earn cash
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Erlyaws-list mailing list
> Erlyaws-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/erlyaws-list
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Sat Dec 30, 2006 1:10 am |
|
|
|
Guest
|
After rereading everything one more time, it just slammed in to me that I'm not
supposed to be passing literal sconf/gconf records in to start_embedded in the
first place. I feel pretty dumb.
I'm still getting crashes, even though I think I'm now using the method as it
was intended:
--------------------------------------------------------------------------------
----------------------------- new version --------------------------------------
--------------------------------------------------------------------------------
make_yaws_start_embedded_crash() ->
yaws:start_embedded(
"/dev/null", % DocRoot
[ { docroot, "/dev/null" },
{ port, 20000 },
{ appmods, [ { "/a-custom-path", root } ] }
], % SL
[ { yaws_dir, "/tmp/logs" },
{ logdir, "/tmp/logs" },
{ tmpdir, "/tmp" }
] % GL
).
--------------------------------------------------------------------------------
------------------------ still crashes with ------------------------------------
--------------------------------------------------------------------------------
1> {"init terminating in
do_boot",{{badrecord,sconf},[{yaws_config,setup_auth,1},{yaws_config,'-add_yaws_auth/1-fun-0-',1},{lists,map,2},{yaws,start_embedded,3},{init,start_it,1},{init,start_em,1}]}}
init terminating in do_boot ()
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
So, I'd still like to add a simpler method (like start() in the ybed.erl example) that
just takes a literal GC, [ [ SC ] ] list and fires things up. Also, can we make
the documentation for the start_embedded methods more explicit, and put them
along with the source (as opposed to on the yaws html documentation page)?
jon
On Fri, Dec 29, 2006 at 04:41:17PM -0800, Jonathan Gold wrote:
Tobbe --
>
> Thank you very much for your reply. Below please find some simple code
> and its shell output that demonstrates how to crash with
> start_embedded/3, as a result of the auth code path.
>
> --------------------------------------------------------------------------------
> --------------------------- begin code snippet ---------------------------------
> --------------------------------------------------------------------------------
>
> -module( test ).
>
> -compile( export_all ).
>
> -include( "yaws_api.hrl" ).
> -include( "yaws.hrl" ).
>
> % Create exactly the gconf we want
> yaws_gconf() ->
>
> Yaws_home = "/tmp/yaws-sandbox",
>
> GConf1 = yaws_config:make_default_gconf( false, "Test" ),
>
> GConf1#gconf{
> yaws_dir = Yaws_home,
> logdir = "/tmp/logs",
> tmpdir = "/tmp"
> }.
>
> % Create exactly the sconf we want
> yaws_sconf() ->
>
> SConf1 = yaws_config:make_default_sconf(),
>
> SConf1#sconf{
> port = 20000,
> docroot = "/dev/null",
> appmods = [ { "/a-custom-path", root } ]
> }.
>
>
> % Crashes on last line
> make_yaws_start_embedded_crash() ->
>
> GC = yaws_gconf(),
> SC = yaws_sconf(),
>
> yaws:start_embedded( "/dev/null", [ GC ], [ [ SC ] ] ).
>
>
> % launches yaws successfully
> skip_using_yaws_start_embedded() ->
>
> application:load( yaws ),
> application:set_env( yaws, embedded, true ),
> application:start( yaws ),
>
> GC = yaws_gconf(),
> SC = yaws_sconf(),
>
> yaws_api:setconf( GC, [ [ SC ] ] ).
>
> --------------------------------------------------------------------------------
> -------------------------- output from crashing code ---------------------------
> --------------------------------------------------------------------------------
>
> $ erl -pa -run test make_yaws_start_embedded_crash
> Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0]
> [kernel-poll:false]
>
> Eshell V5.5.2 (abort with ^G)
> 1> {"init terminating in
> do_boot",{{badrecord,sconf},[{yaws_config,setup_auth,1},{yaws_config,'-add_yaws_auth/1-fun-0-',1},{lists,map,2},{yaws,start_embedded,3},{init,start_it,1},{init,start_em,1}]}}
> init terminating in do_boot ()
>
>
> --------------------------------------------------------------------------------
> -------------------------- output from working code ----------------------------
> --------------------------------------------------------------------------------
>
> $ erl -run test skip_using_yaws_start_embedded
> Erlang (BEAM) emulator version 5.5.2 [source] [async-threads:0]
> [kernel-poll:false]
>
> Eshell V5.5.2 (abort with ^G)
> 1>
> =INFO REPORT==== 29-Dec-2006::16:34:27 ===
> Yaws: Listening to 127.0.0.1:20000 for servers
> - http://localhost:20000 under /dev/null
>
>
> --------------------------------------------------------------------------------
> ------------------------- back to the discussion... ----------------------------
> --------------------------------------------------------------------------------
>
>
> I hope what follows isn't too out of place, but I feel like it's more
> resopnsible for me to press my point a little bit rather than silently shrug my
> shoulders and just fork my own version of these methods at this point. In
> particular, it seems that:
>
> - The fact that the GC and SC records I pass in are not the ones ultimately
> passed on to yaws_api:setconf is an underlying problem.
>
> - This problem is compounded by the presence of the
> yaws_config:add_yaws_auth code (which seems to ultimately result in the
> crash)
>
> - The method is doing too many things inside a single code path. Another
> example of this seems to be the "DocRoot" parameter (required), which can
> be redundant (as it is in my case) and without meaning in the case of
> servers which don't serve actual documents from the file system.
>
> I think it comes down to what is duscussed in Appendix B, Section 3.9 (p 221) of
> Joe Armstrong's thesis. That section discusses the "principle of 'least
> astonishment,'" and concludes with the sentence, "If you get astonished by what
> a function does, either your function solves the wrong problem or it has a wrong
> name." I'm thinking that's the problem here.
>
> Can I suggest that we add a new method named something like
> start_minimal_embedded (or a new signature for start_embedded that matches on
> the atomic tag 'minimal') to change this? If that's met with a favorable
> response, I'd enjoy having the chance to do it, get it reviewed by the Yaws
> team, and submit it back to the project.
>
> Thank you again for all of your work and attention.
>
> jon
>
>
>
> On Fri, Dec 29, 2006 at 07:35:01PM +0100, Torbjorn Tornkvist wrote:
> > Jonathan Gold skrev:
> > > I've just started using start_embedded (mainly start_embedded/3 with
> > > my own GL and SL), and have a question about some of the design
> > > decisions behind that method. I've searched the archives and read
> > > these threads:
> > >
> > > http://sourceforge.net/mailarchive/message.php?msg_id=36726870
> > > http://sourceforge.net/mailarchive/message.php?msg_id=37687506
> > >
> > > but still have some questions.
> > >
> > > What is the purpose of these lines (45-48 of yaws.erl:start_embedded/3
> > > in my 1.66 distro):
> > >
> > > GC = setup_gconf(GL, yaws_config:make_default_gconf(false, "")),
> > > SC = setup_sconf(DocRoot, #sconf{}, SL),
> > > yaws_config:add_yaws_soap_srv(GC),
> > > yaws_config:add_yaws_auth(SL),
> >
> > I dont think you you need to be worried about the two lines above.
> > add_yaws_soap_srv/1 will only do things if: GC#gconf.enable_soap == true
> > and if so: start the yaws_soap_srv server.
> >
> > add_yaws_auth/1 works in a similar way.
> >
> > Cheers, Tobbe
> >
> > >
> > > I was surprised to find them as I worked through getting my first
> > > instance to come up, since I figured that if I passed in a GL and SL
> > > then they would be used as-is. I'm also trying to understand the
> > > inclusion of The soap/auth stuff as well, since in my case I'd rather
> > > not follow those code paths by default.
> > >
> > > As it is, I'm just using my own method which does what
> > > start_embedded/3 does but without the lines above, since the lines
> > > above make me a bit uncomfortable and I don't need them.
> > >
> > > jon
> > >
> > > -------------------------------------------------------------------------
> > > Take Surveys. Earn Cash. Influence the Future of IT
> > > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > > opinions on IT & business topics through brief surveys - and earn cash
> > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> >
> >
> > -------------------------------------------------------------------------
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > opinions on IT & business topics through brief surveys - and earn cash
> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Erlyaws-list mailing list
> > Erlyaws-list@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/erlyaws-list
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Erlyaws-list mailing list
> Erlyaws-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/erlyaws-list
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|