<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>blog.tornkvist.org</title>
    <link>http://blog.tornkvist.org/rss.yaws</link>
    <description>
     Contains the blog.tornkvist.org blog. Ramblings about Erlang,Yaws,jQuery and Ajax.
    </description>
    <language>en</language><item>
<title>Masterbrain - A 'rev-proxy' like dispatcher.</title>
<link>http:/blog.tornkvist.org/blog.yaws?id=1206648282638429</link>
<guid>http:/blog.tornkvist.org/blog.yaws?id=1206648282638429</guid>
<description>&lt;p&gt;On my server at home I'm running a number of experimental systems &lt;br /&gt;
written in Erlang. Many of them have a web interface that I want &lt;br /&gt;
to expose to the Internet. Since I want them to be accessible as &lt;br /&gt;
subdomains of tornkvist.org, and on port 80; I have been using &lt;br /&gt;
lighttpd in front of them as a rev-proxy. This has been a bit &lt;br /&gt;
of annoyance since I have had to deal with the lighttpd's &lt;br /&gt;
configuration as well as my Yaws configuration for each system &lt;br /&gt;
of mine.                                                                                                                                                                                                            &lt;/p&gt;

&lt;h1&gt;The Idea&lt;/h1&gt;

&lt;p&gt;This morning, on the way to work, I came up with a nice solution &lt;br /&gt;
that would make it possible to get rid of lighttpd and &lt;br /&gt;
in fact; also get rid of each Yaws server running on my systems.                                                                                                                                                    &lt;/p&gt;

&lt;p&gt;The idea is very simple. On my server I will run one Erlang node &lt;br /&gt;
that runs Yaws. This is my web server. I configure Yaws to virt-host &lt;br /&gt;
my other systems, pointing the docroot accordingly for each of &lt;br /&gt;
the system. Then for each system I make sure that every .yaws file &lt;br /&gt;
only contains one single rpc-call to the actual system node. The &lt;br /&gt;
result from the rpc-call must be consumable by the Yaws server.                                                                                                                                                     &lt;/p&gt;

&lt;p&gt;This means that none of my systems anylonger need to run Yaws of &lt;br /&gt;
their own. It also results in that no traditional rev-proxy work, &lt;br /&gt;
a la lighttpd, is needed. And as the final touch; it also makes &lt;br /&gt;
it possible to implement a simple form of load balancing.   &lt;/p&gt;

&lt;p&gt;So for example, my &lt;em&gt;index.yaws&lt;/em&gt; of my eblog system now contains:                                                                                                                                                    &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;erl&amp;gt;                                                                                                                                                                                                           
out(A) -&amp;gt;                                                                                                                                                                                                       
    mbrain:call(eblog, index, out, [A]).                                                                                                                                                                        
&amp;lt;/erl&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The content that previously was located in &lt;em&gt;index.yaws&lt;/em&gt; has now &lt;br /&gt;
moved into &lt;em&gt;index.erl&lt;/em&gt;. The &lt;code&gt;mbrain:call/4&lt;/code&gt; function, which &lt;br /&gt;
executes in the Yaws server node,  will check if there exist &lt;br /&gt;
any nodes that match &lt;code&gt;eblog@HOST&lt;/code&gt;, and if so; it make an &lt;br /&gt;
&lt;code&gt;rpc:call/4&lt;/code&gt; to that node. If there are several node names that &lt;br /&gt;
match, one of them is picked by random. It is also possible to &lt;br /&gt;
specify a list of node names to &lt;code&gt;mbrain:call/4&lt;/code&gt; to cater for &lt;br /&gt;
the case where you want to load balance several nodes on the &lt;br /&gt;
same host.                                                                                                                                                                                                          &lt;/p&gt;

&lt;h1&gt;Summary&lt;/h1&gt;

&lt;p&gt;So there you go; a simple rev-proxy like, load balancing, &lt;br /&gt;
front end dispatcher. The code can be found in my &lt;br /&gt;
&lt;a href=&quot;http://www.tornkvist.org/gitweb&quot;&gt;git repos&lt;/a&gt;. You can &lt;br /&gt;
reach two of my systems that are located behind my &lt;br /&gt;
&lt;em&gt;Masterbrain dispatcher&lt;/em&gt;; one is my &lt;br /&gt;
&lt;a href=&quot;http://blog.tornkvist.org/&quot;&gt;blog site&lt;/a&gt; and &lt;br /&gt;
the other is &lt;a href=&quot;http://tpl.tornkvist.org/&quot;&gt;The Priority List&lt;/a&gt; &lt;br /&gt;
site.                                                                                                                                                                                                               &lt;/p&gt;

&lt;h1&gt;Final remark&lt;/h1&gt;

&lt;p&gt;To only have a single function call in your &lt;em&gt;.yaws&lt;/em&gt; file &lt;br /&gt;
is actually very good. It makes both debugging and hot &lt;br /&gt;
code replacement easier.&lt;/p&gt;
</description>
<dc:creator>tobbe</dc:creator>
<dc:date>2008-03-27T21:04:42+01:00</dc:date>
</item>
<item>
<title>The dsl_engine demo</title>
<link>http:/blog.tornkvist.org/blog.yaws?id=1210164473208550</link>
<guid>http:/blog.tornkvist.org/blog.yaws?id=1210164473208550</guid>
<description>&lt;p&gt;I have been trying out 
&lt;a href=&quot;http://www.erlware.org/&quot; title=&quot;erlware.org&quot;&gt;Erlware&lt;/a&gt; recently; and
I like it a lot! &lt;/p&gt;

&lt;p&gt;As an example, I created a demo application that show the use of the dsl_engine I wrote about earlier. Now, before I explain in more detail how I did this with the Erlware tools; here is how to try it out:&lt;/p&gt;

&lt;p&gt;wget http://faxien.googlecode.com/files/faxien-launcher-universal-0.3.3.py
  sudo python faxien-launcher-universal-0.3.3.py
  sudo /usr/local/erlware/bin/faxien install-release dsl&lt;em&gt;engine&lt;/em&gt;demo
  /usr/local/erlware/bin/dsl&lt;em&gt;engine&lt;/em&gt;demo&lt;/p&gt;

&lt;p&gt;Point your browser to: http://localhost:9898/&lt;/p&gt;
</description>
<dc:creator>tobbe</dc:creator>
<dc:date>2008-05-07T14:47:53+02:00</dc:date>
</item>
  </channel>
</rss>
