<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Trypticon: Directions for Action Messenger</title>
    <link>http://trypticon.org/articles/2006/05/22/directions-for-action-messenger</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>If it ain't broke, break it.</description>
    <item>
      <title>Directions for Action Messenger</title>
      <description>&lt;p&gt;Well, the first highly experimental release of &lt;a href="http://trypticon.org/software/actionmessenger/" title="Action Messenger"&gt;Action Messenger&lt;/a&gt; experienced a small amount of success, and a couple of people spotted some bugs which have been fixed in version 0.1.1.&lt;/p&gt;

&lt;p&gt;So now that everything works for small apps, how does it grow?  I do want to integrate into Typo,  and the default deployment for Typo uses FastCGI.  Whereas each FastCGI process is relatively long-lived, there are multiple instances, and they can&amp;#8217;t all be logged in at once [with the same resource.]&lt;/p&gt;&lt;p&gt;So I have a number of options for coping with having Action Messenger work from multiple Rails instances.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Have each instance login from a different resource.  This is the simplest approach, and the one which I&amp;#8217;m currently using on this site&amp;#8217;s Typo install: append the process ID onto the resource when logging in.  The main downside to this approach is that when I add presence support in, users who have added the bot would see all its multiple resources logged in at once.  Whereas this would start out fairly small (I use 5 instances on my Typo) for larger, more popular sites, you might end up with a few dozen bots online at the same time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have one instance of Rails nominate it as the master, and start a DRb server on a background thread.  The other instances would connect to the master when they need to send a message.  This would be the simplest approach for the end user, but seems difficult to implement.  Which server becomes the master?  Perhaps an instance simply tries to open a socket to the server, and if it fails, it tries to open a socket as the server.  In this fashion, there is always only one instance online, and when that instance goes offline (e.g. the process crashes) another one would pick it up.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have the Rails app spawn a separate process to handle the server side of things, but otherwise do things exactly as #2.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use something such as &lt;a href="http://opensvn.csie.org/ezra/rails/backgroundrb/" title="BackgrounDRb"&gt;BackgrounDRb&lt;/a&gt; to run the bot as one thread of a much more flexible server.  This approach is probably the most useful as things other than a Jabber bot might be run in this server, although at the moment I&amp;#8217;m not sure what.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write a simple, specialist Ruby bot, and require that bot to be started completely separately from Rails.  The Rails instances would then connect to the bot whenever they need something.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At the moment, #5 is my favourite option.  My main problem with this approach is &amp;#8211; how will the bot handle receiving messages?  Accessing the Rails models directly from the bot isn&amp;#8217;t the problem, the problem is coming up with an API just as clean as the current one.&lt;/p&gt;</description>
      <pubDate>Mon, 22 May 2006 22:16:00 +1000</pubDate>
      <guid isPermaLink="false">urn:uuid:86f30d27-e17a-403e-bb1a-08dee872330f</guid>
      <author>Trejkaz</author>
      <link>http://trypticon.org/articles/2006/05/22/directions-for-action-messenger</link>
      <category>software</category>
      <category>jabber</category>
      <category>rails</category>
      <category>ruby</category>
      <category>actionmessenger</category>
    </item>
  </channel>
</rss>
