<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>templates/mongrel</filename>
    </added>
    <added>
      <filename>templates/thin</filename>
    </added>
    <added>
      <filename>test/fixtures/thin_cluster.conf</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,14 +1,15 @@
 h1. monit_conf
 
-monit_conf is a script that generates monit configuration file(s) from one or more mongrel cluster configuration files.
+monit_conf is a script that generates monit configuration file(s). It can generate monit configuration files from both thin and mongrel cluster configuration files.
+
 
 Using monit_conf has the following benefits:
 
-* Easier to setup monit correctly.
+* Easier to setup monit to correctly monitor thin and mongrel servers.
 * Uses a proven monit configuration file that handles mongrel crashes and stale pids correctly.
 
-The script looks for mongrel cluster configuration files (eg. mongrel_cluster.yml) in the specified directory, 
-and generates one configuration file for every mongrel cluster configuration file it finds.
+The script looks for thin and mongrel cluster configuration files (thin_cluster.conf and mongrel_cluster.yml) in the specified directory, 
+and generates one configuration file for every cluster configuration file it finds.
 
 h2. Install
 
@@ -22,7 +23,7 @@ rake install_gem
 
 h2. Requirements
 
-Currently monit_conf assumes that you have mongrel_cluster.yml in RAILS_ROOT/config (can be a link).
+Currently monit_conf assumes that you have thin_cluster.conf and/or mongrel_cluster.yml in RAILS_ROOT/config (can be a link).
 
 h2. Usage
 
@@ -32,12 +33,12 @@ To generate the monit configuration run the monit_conf command:
 	&lt;code&gt;
 $ monit_conf 
 
-  Searching for 'mongrel_cluster.yml' in '/var/www/**/current/**'
+  Searching for '{thin_cluster.conf,mongrel_cluster.yml}' in '/var/www/**/current/**'
 
 	&lt;/code&gt;
 &lt;/pre&gt;
 
-As you can see the script will by default look for mongrel_cluster.yml files in /var/www/**/current/**.
+As you can see the script will by default look for thin_cluster.conf and mongrel_cluster.yml files in /var/www/**/current/**.
 
 See the help documentation for details on how to change this behavior:
 
@@ -48,11 +49,10 @@ $ monit_conf  --help
 Usage: monit_conf [OPTIONS]
     
 
-Generates monit configuration file(s) from one or more mongrel cluster configuration files.
-
-Script looks for mongrel cluster configuration files (eg. mongrel_cluster.yml) in the specified directory, 
-and generates a separate configuration file for each mongrel cluster configuration found.
+Generates monit configuration file(s) from one or more thin/mongrel cluster configuration files.
 
+The script searches for thin and mongrel cluster configuration files (thin_cluster.conf and mongrel_cluster.yml) in the specified directory, 
+and generates a separate configuration file for each cluster configuration found.
 
 
 Optional arguments:
@@ -60,10 +60,10 @@ Optional arguments:
                                    Default: /var/www/**/current/**
       --output=[val]               Where monit configuration files will be written.
                                    Default: /etc/monit/include
-      --mongrel_conf=[val]         Name of mongrel cluster configuration, usually mongrel_cluster.yml.
-                                   Default: mongrel_cluster.yml
-      --monit_template=[val]       The template used when generating monit configuration files.
-                                   Default: /usr/local/lib/ruby/gems/1.8/gems/monit_conf-0.0.1/templates/monit_include
+      --pattern=[val]              Pattern that matches mongrel and/or thin configuration files (Dir.glob syntax).
+                                   Default: {thin_cluster.conf,mongrel_cluster.yml}
+      --template_dir=[val]         The directory where monit templates for thin and mongrel are found.
+                                   Default: /usr/local/lib/ruby/gems/1.8/gems/monit_conf-x.x.x/templates/
 
   -h, --help                       Show this help message.
 
@@ -108,6 +108,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 h2. Todo
 
 * Better group names
+* Better defaults (we're assuming that the configuration files contains xyz at the moment)
+* Refactor
 
 h2. Author
 </diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -21,8 +21,8 @@ end
 OPTIONS = {
   :output          =&gt; &quot;/etc/monit/include&quot;,
   :input           =&gt; &quot;/var/www/**/current/**&quot;,
-  :mongrel_conf    =&gt; &quot;mongrel_cluster.yml&quot;,
-  :monit_template  =&gt; File.expand_path(&quot;#{root_dir}/templates/monit_include&quot;)
+  :pattern         =&gt; &quot;{mongrel_cluster.yml,thin_cluster.conf}&quot;,
+  :template_dir    =&gt; File.expand_path(&quot;#{root_dir}/templates/&quot;)
 }
 
 # Parse options
@@ -48,17 +48,17 @@ and generates a separate configuration file for each mongrel cluster configurati
     o.separator   &quot;Optional arguments:&quot;
 
     o.on(&quot;--input=[val]&quot;, String,
-         &quot;Where to look for mongrel_cluster.yml files. Also see --mongrel_conf switch.&quot;,
+         &quot;Directory where configuration files are located. Also see --pattern switch.&quot;,
          &quot;Default: #{OPTIONS[:input]}&quot;)   { |OPTIONS[:input]| }
     o.on(&quot;--output=[val]&quot;, String,
         &quot;Where monit configuration files will be written.&quot;,
         &quot;Default: #{OPTIONS[:output]}&quot;)   { |OPTIONS[:output]| }
-    o.on(&quot;--mongrel_conf=[val]&quot;, String,
-         &quot;Name of mongrel cluster configuration, usually mongrel_cluster.yml.&quot;,
-         &quot;Default: #{OPTIONS[:mongrel_conf]}&quot;)   { |OPTIONS[:mongrel_conf]| }
-    o.on(&quot;--monit_template=[val]&quot;, String,
-        &quot;The template used when generating monit configuration files.&quot;,
-        &quot;Default: #{OPTIONS[:monit_template]}&quot;)   { |OPTIONS[:monit_template]| }
+    o.on(&quot;--pattern=[val]&quot;, String,
+         &quot;Pattern used for finding configuration files, usually mongrel_cluster.yml, thin_cluster.conf or a combination {mongrel_cluster.yml,thin_cluster.conf}.&quot;,
+         &quot;Default: #{OPTIONS[:pattern]}&quot;)   { |OPTIONS[:pattern]| }
+    o.on(&quot;--template_dir=[val]&quot;, String,
+        &quot;The directory where templates are stored. These are used when generating monit configuration files.&quot;,
+        &quot;Default: #{OPTIONS[:template_dir]}&quot;)   { |OPTIONS[:template_dir]| }
 
     o.separator &quot;&quot;
 </diff>
      <filename>bin/monit_conf</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 require 'yaml'
 require 'fileutils'
 
+# TODO Thin support was added in a hurry so code needs some refactoring.
+
 module MonitConf
   
   class Generator
@@ -10,30 +12,44 @@ module MonitConf
         
         #raise options.inspect
 
-        monit_template = options[:monit_template]        
-        mongrel_conf   = options[:mongrel_conf]
+        template_dir   = options[:template_dir]        
+        pattern        = options[:pattern]
         input          = options[:input]
         output         = options[:output]
         
         puts &quot;
-  Searching for '#{mongrel_conf}' in '#{input}'
+  Searching for '#{pattern}' in '#{input}'
         &quot;
-        Dir.glob(&quot;#{input}/#{mongrel_conf}&quot;).each do |file|
+        Dir.glob(&quot;#{input}/#{pattern}&quot;).each do |file|
 
           vars = YAML::load(File.open(file))
-          
-          vars['mongrel_conf'] = mongrel_conf if !vars.has_key?(:mongrel_conf)
+          vars['configuration'] = file if !vars.has_key?(:configuration)
 
           start_port = vars['port'].to_i
           end_port   = start_port + vars['servers'].to_i
 
+          template   = &quot;&quot;
           monit_conf = &quot;&quot;
           
+          # Detect thin configuration files
+          # TODO Refactor
+          is_thin = file =~ /thin/
+
+          if is_thin
+            template         = &quot;#{template_dir}/thin&quot;
+            vars['cwd']      = vars['chdir'] if vars.has_key?('chdir')
+            vars['pid_file'] = vars['pid'] if vars.has_key?('pid')
+          else # Assume it's a mongrel configuration file
+            template = &quot;#{template_dir}/mongrel&quot;
+          end
+
           # Fine tune settings
           vars['cwd']      = &quot;#{vars['cwd']}/&quot; if vars['cwd'][-1,1] != '/' # cwd should end with /
-          vars['name']     = &quot;mongrel-#{start_port}-#{end_port}&quot; if !vars.has_key?('name') # better names if name is not set
+          vars['name']     = &quot;#{start_port}-#{end_port}&quot; if !vars.has_key?('name') # better names if name is not set
           vars['pid_file'] = &quot;#{vars['cwd']}#{vars['pid_file']}&quot; if vars['pid_file'][0,1] != '/' # Make pid path absolute
           
+          index = 0
+
           while start_port &lt; end_port
             server_vars = vars.dup
             
@@ -41,12 +57,19 @@ module MonitConf
             # Trim the pid_file extension and add the correct port
             server_vars['pid_file']     = vars['pid_file'].gsub(/\.pid$/, '')
             server_vars['pid_file']     = &quot;#{server_vars['pid_file']}.#{server_vars['port']}.pid&quot;
-            
-            server_vars['mongrel_conf'] = file
+            server_vars['index']        = index
+
+            # TODO Refactor
+            if is_thin
+              server_vars['socket']     = vars['socket'].gsub(/\.sock$/, '')
+              server_vars['socket']     = &quot;#{server_vars['socket']}.#{index}.sock&quot;
+            end
+
+            server_vars['configuration'] = File.expand_path(file)
             
             start_port = start_port + 1
-            
-            monit_conf = monit_conf + MonitConf::Template.new(monit_template).exec(server_vars)
+            index = index + 1
+            monit_conf = monit_conf + MonitConf::Template.new(template).exec(server_vars)
           end
  
           filename = &quot;#{output}/#{vars['name']}&quot;
@@ -63,4 +86,4 @@ module MonitConf
     end
   end
 
-end
\ No newline at end of file
+end</diff>
      <filename>lib/monit_conf/generator.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>pkg/monit_conf-0.0.1.gem</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1.tgz</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/History.txt</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/Manifest.txt</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/PostInstall.txt</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/README.rdoc</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/Rakefile</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/bin/monit_conf</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/lib/monit_conf.rb</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/lib/monit_conf/generator.rb</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/lib/monit_conf/template.rb</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/templates/monit_include</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/test/test_helper.rb</filename>
    </removed>
    <removed>
      <filename>pkg/monit_conf-0.0.1/test/test_monit_conf.rb</filename>
    </removed>
    <removed>
      <filename>templates/monit_include</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>f001fc9793eb0bb952389e57e7b378b53ac19be1</id>
    </parent>
  </parents>
  <author>
    <name>Christian Hellsten</name>
    <email>christian.hellsten@gmail.com</email>
  </author>
  <url>http://github.com/christianhellsten/monit_conf/commit/b3c26feb879851933a5b45b79a08290e20ae31e2</url>
  <id>b3c26feb879851933a5b45b79a08290e20ae31e2</id>
  <committed-date>2008-12-29T14:42:36-08:00</committed-date>
  <authored-date>2008-12-29T14:42:36-08:00</authored-date>
  <message>Added thin support. Code needs to be refactored later...</message>
  <tree>35fc6e70848038d4024baa4949b16a756802ccc1</tree>
  <committer>
    <name>Christian Hellsten</name>
    <email>christian.hellsten@gmail.com</email>
  </committer>
</commit>
