<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pivotal Labs &#187; unicorn</title>
	<atom:link href="http://pivotallabs.com/tag/unicorn/feed/" rel="self" type="application/rss+xml" />
	<link>http://pivotallabs.com</link>
	<description>Agility Developed</description>
	<lastBuildDate>Tue, 21 May 2013 05:27:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>[NY] Standup 1/25</title>
		<link>http://pivotallabs.com/ny-standup-125/</link>
		<comments>http://pivotallabs.com/ny-standup-125/#comments</comments>
		<pubDate>Fri, 25 Jan 2013 16:15:58 +0000</pubDate>
		<dc:creator>Herval Freire</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[unicorn]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=11827</guid>
		<description><![CDATA[<p>Interestings Beware of absolute paths when using unicorn and USR2 Using unicorns USR2 signal to restart does NOT re-read your unicorn config so be very careful with Capistrano deployments. See SO Q&#38;A for details below: http://stackoverflow.com/questions/9388074/restarting-unicorn-with-usr2-doesnt-seem-to-reload-production-rb-settings Additionally you should specify several things in the config file, specifically the gemfile, or it won&#8217;t reload that either. APP_ROOT = DIR ENV['BUNDLE_GEMFILE'] = DIR/Gemfile</p><p>The post <a href="http://pivotallabs.com/ny-standup-125/">[NY] Standup 1/25</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Interestings</h2>
<h3>Beware of absolute paths when using unicorn and USR2</h3>
<p>Using unicorns USR2 signal to restart does NOT re-read your unicorn config so be very careful with Capistrano deployments. See SO Q&amp;A for details below:</p>
<p><a href="http://stackoverflow.com/questions/9388074/restarting-unicorn-with-usr2-doesnt-seem-to-reload-production-rb-settings">http://stackoverflow.com/questions/9388074/restarting-unicorn-with-usr2-doesnt-seem-to-reload-production-rb-settings</a></p>
<p>Additionally you should specify several things in the config file, specifically the gemfile, or it won&#8217;t reload that either.<br />
APP_ROOT = DIR<br />
ENV['BUNDLE_GEMFILE'] = DIR/Gemfile</p>
<p>The post <a href="http://pivotallabs.com/ny-standup-125/">[NY] Standup 1/25</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/ny-standup-125/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to split up rails 3.x logger by unicorn workers</title>
		<link>http://pivotallabs.com/how-to-split-up-rails-3-x-by-unicorn-workers/</link>
		<comments>http://pivotallabs.com/how-to-split-up-rails-3-x-by-unicorn-workers/#comments</comments>
		<pubDate>Fri, 11 Jan 2013 14:34:44 +0000</pubDate>
		<dc:creator>Ryan Ong</dc:creator>
				<category><![CDATA[Labs]]></category>
		<category><![CDATA[logger]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[unicorn]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/?p=11614</guid>
		<description><![CDATA[<p>TLDR: Put this in your unicorn config. Make sure not to have duplicate after_fork calls after_fork do &#124;server, worker&#124; if defined?(ActiveSupport::TaggedLogging) &#38;&#38; Rails.logger.kind_of?(ActiveSupport::TaggedLogging) Rails.logger.instance_eval do level = @logger.level # flush and close logger to make sure we don't cut off any potential logging before this @logger &#38;&#38; @logger.flush &#38;&#38; @logger.close @logger = ActiveSupport::BufferedLogger.new(Rails.root.join("log", "rails_#{Rails.env}.#{worker.nr}.log").to_s, level) end elsif Rails.logger.kind_of?(ActiveSupport::BufferedLogger) Rails.logger.instance_eval do @log &#38;&#38; @log.flush &#38;&#38; @log.close @log_path = Rails.root.join("log", "rails_#{Rails.env}.#{worker.nr}.log").to_s if respond_to?(:open_logfile, true) @log = open_logfile(@log_path) elsif respond_to?(:open_log, true) if File.exist?(@log_path) @log = open_log(@log_path, (File::WRONLY &#124; File::APPEND)) else FileUtils.mkdir_p(File.dirname(@log_path)) @log = open_log(l@log_path, (File::WRONLY &#124; File::APPEND &#124; File::CREAT)) end end end end end How this works! There is no easy way to change the path of a log or swap out the logger. When rails is instantiated ActionController and ActiveRecord assigns their local logger from Rails.logger. So if you reassign Rails.logger to a new one ActionController and ActiveRecord will continue to use&#8230;</p><p>The post <a href="http://pivotallabs.com/how-to-split-up-rails-3-x-by-unicorn-workers/">How to split up rails 3.x logger by unicorn workers</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>TLDR: Put this in your unicorn config. Make sure not to have duplicate after_fork calls</p>
<pre><code>after_fork do |server, worker|
  if defined?(ActiveSupport::TaggedLogging) &amp;&amp; Rails.logger.kind_of?(ActiveSupport::TaggedLogging)
    Rails.logger.instance_eval do
      level = @logger.level
      # flush and close logger to make sure we don't cut off any potential logging before this
      @logger &amp;&amp; @logger.flush &amp;&amp; @logger.close
      @logger = ActiveSupport::BufferedLogger.new(Rails.root.join("log", "rails_#{Rails.env}.#{worker.nr}.log").to_s, level)
    end
  elsif Rails.logger.kind_of?(ActiveSupport::BufferedLogger)
    Rails.logger.instance_eval do
      @log &amp;&amp; @log.flush &amp;&amp; @log.close
      @log_path = Rails.root.join("log", "rails_#{Rails.env}.#{worker.nr}.log").to_s
      if respond_to?(:open_logfile, true)
        @log = open_logfile(@log_path)
      elsif respond_to?(:open_log, true)
        if File.exist?(@log_path)
          @log = open_log(@log_path, (File::WRONLY | File::APPEND))
        else
          FileUtils.mkdir_p(File.dirname(@log_path))
          @log = open_log(l@log_path, (File::WRONLY | File::APPEND | File::CREAT))
        end
      end
    end
  end
end<code></code></code></pre>
<h2>How this works!</h2>
<p>There is no easy way to change the path of a log or swap out the logger. When rails is instantiated <a href="https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_controller/railtie.rb" target="_blank">ActionController</a> and <a href="https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/railtie.rb#L41" target="_blank">ActiveRecord</a> assigns their local logger from Rails.logger. So if you reassign Rails.logger to a new one ActionController and ActiveRecord will continue to use the old rails logger.</p>
<p>There are no methods to change or swap out the log path in the Logging class. In order to change the log path we have to change instance variables to either a new logger or a new file handler.</p>
<p>In <a href="https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/application/bootstrap.rb" target="_blank">Rails 3.2</a> <a href="https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/tagged_logging.rb" target="_blank">ActiveSupport::TaggedLogging</a> was added!<br />
If you look here you can see how Rails.logger is assigned! (<a href="https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/application/bootstrap.rb#L24">source</a>)<br />
As you can see TaggedLogging basically just wraps a buffered logger. So when we open up Rails.logger we can patch what TaggedLogging wraps by modifying the <a href="https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/tagged_logging.rb#L17" target="_blank">@logger</a> variable.<br />
If TaggedLogging isn&#8217;t used we can use the open_logfile command and just insert a path.</p>
<p>In <a href="https://github.com/rails/rails/blob/3-0-stable/railties/lib/rails/application/bootstrap.rb" target="_blank">Rails 3.0</a> and <a href="https://github.com/rails/rails/blob/3-1-stable/railties/lib/rails/application/bootstrap.rb" target="_blank">Rails 3.1</a> TaggedLogging isn&#8217;t used and by default uses <a href="https://github.com/rails/rails/blob/3-0-stable/activesupport/lib/active_support/buffered_logger.rb" target="_blank">BufferedLogger</a>.<br />
We have to create a new file handler using the <a href="https://github.com/rails/rails/blob/3-1-stable/activesupport/lib/active_support/buffered_logger.rb#L58" target="_blank">open_log</a> method and reassign the <a href="https://github.com/rails/rails/blob/3-0-stable/activesupport/lib/active_support/buffered_logger.rb#L51" target="_blank">@log</a> variable.</p>
<p>The post <a href="http://pivotallabs.com/how-to-split-up-rails-3-x-by-unicorn-workers/">How to split up rails 3.x logger by unicorn workers</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/how-to-split-up-rails-3-x-by-unicorn-workers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Standup 9/9/2009: Unicorn, Thin, and Mongrel</title>
		<link>http://pivotallabs.com/standup-9-9-2009-unicorn-thin-and-mongrel/</link>
		<comments>http://pivotallabs.com/standup-9-9-2009-unicorn-thin-and-mongrel/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 14:39:00 +0000</pubDate>
		<dc:creator>Pivotal Labs</dc:creator>
				<category><![CDATA[Standup]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[thin]]></category>
		<category><![CDATA[unicorn]]></category>

		<guid isPermaLink="false">http://pivotallabs.com/standup-9-9-2009-unicorn-thin-and-mongrel/</guid>
		<description><![CDATA[<p><h2>Ask for Help</h2>

<blockquote>
    <p><em>"Has anyone used <a href="http://unicorn.bogomips.org/">Unicorn</a>"</em></p>
</blockquote>

<p>No one present is using Unicorn. Some wondered how it differs from <a href="http://code.macournoyer.com/thin/">Thin</a>. </p>

<p>This raised the question:</p>

<blockquote>
    <p><em>"Is there a road map for mongrel and rails? Mongrel uses CGI and Rails 2.3 has removed CGI."</em></p>
</blockquote>

<p>In the <a href="http://guides.rubyonrails.org/2_3_release_notes.html#deprecated">Ruby on Rails 2.3 Release Notes</a>, there is the statement</p>

<blockquote>
    <p>...but if you use CGI, don’t worry; Rails now supports CGI
    through a proxy interface...</p>
</blockquote> <a href="http://pivotallabs.com/standup-9-9-2009-unicorn-thin-and-mongrel/">Continue reading <span class="meta-nav">&#8594;</span></a></p><p>The post <a href="http://pivotallabs.com/standup-9-9-2009-unicorn-thin-and-mongrel/">Standup 9/9/2009: Unicorn, Thin, and Mongrel</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>Ask for Help</h2>
<blockquote>
<p><em>&#8220;Has anyone used <a href="http://unicorn.bogomips.org/">Unicorn</a>&#8220;</em></p>
</blockquote>
<p>No one present is using Unicorn. Some wondered how it differs from <a href="http://code.macournoyer.com/thin/">Thin</a>. </p>
<p>This raised the question:</p>
<blockquote>
<p><em>&#8220;Is there a road map for mongrel and rails? Mongrel uses CGI and Rails 2.3 has removed CGI.&#8221;</em></p>
</blockquote>
<p>In the <a href="http://guides.rubyonrails.org/2_3_release_notes.html#deprecated">Ruby on Rails 2.3 Release Notes</a>, there is the statement</p>
<blockquote>
<p>&#8230;but if you use CGI, don’t worry; Rails now supports CGI<br />
    through a proxy interface&#8230;</p>
</blockquote>
<p>The post <a href="http://pivotallabs.com/standup-9-9-2009-unicorn-thin-and-mongrel/">Standup 9/9/2009: Unicorn, Thin, and Mongrel</a> appeared first on <a href="http://pivotallabs.com">Pivotal Labs</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://pivotallabs.com/standup-9-9-2009-unicorn-thin-and-mongrel/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using apc
Database Caching 3/9 queries in 0.006 seconds using apc
Object Caching 569/585 objects using apc

 Served from: pivotallabs.com @ 2013-05-21 09:38:01 by W3 Total Cache -->