<?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>A Noted Path by Theodore Nguyen-Cao &#187; unix</title>
	<atom:link href="http://www.theodorenguyen-cao.com/tag/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theodorenguyen-cao.com</link>
	<description>Personal blog of Theodore Nguyen-Cao</description>
	<lastBuildDate>Wed, 21 Jul 2010 15:40:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Rails initial request slow with mod_rails</title>
		<link>http://www.theodorenguyen-cao.com/2008/12/07/rails-initial-request-slow-with-mod-rails/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/12/07/rails-initial-request-slow-with-mod-rails/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 18:20:08 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.theodorenguyen-cao.com/?p=158</guid>
		<description><![CDATA[Following up on my previous post , I&#8217;ve been experience slow load times (10-15 secs) on the initial request after application restarts. This has to do with the way mod_rails manages application instances (Although, I experienced this when using mongrel_cluster and proxy balancers). It will spin up instances on page request and each instance has [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on my previous <a href="http://www.theodorenguyen-cao.com/2008/12/06/setting-up-phusion-passenger-mod_rails-with-capistrano-support/">post</a> , I&#8217;ve been experience slow load times (10-15 secs) on the initial request after application restarts.  This has to do with the way mod_rails manages application instances (Although, I experienced this when using mongrel_cluster and proxy balancers).  It will spin up instances on page request and each instance has an idle timeout.  This just means after the timeout expires, mod_rails will shutdown that instance to conserve memory allocation.  While you can change timeout value (see <a href="http://www.modrails.com/documentation/Users%20guide.html#PassengerPoolIdleTime">PassengerPoolIdleTime</a>), this will only cause all instances that get spin up to live longer. After high load times, these instances will stick around longer than neccessary.</p>
<p>For low traffic sites (like mine), this idle timeout may be reached causing the next visitor to our website to experience a really long delay before page load.  What we really want is an option to set a minimum number of instances.  This would allow us to automatically spin up an instance during start up and keep it around.  Unfortunately at this time, it doesn&#8217;t look like there is a way to set this.  </p>
<p>As a workaround, I&#8217;ve setup a crontab that makes a request to my application every 5 minutes to prevent  mod_rails from killing off all application instances.</p>
<p>To do this just run:</p>
<pre name="code" class="console">crontab -e</pre>
<p>And then specific the following cron</p>
<pre name="code" class="console">
*/5 * * * * wget -O /dev/null http://www.myapp.com 2>/dev/null
</pre>
<p>You can verify this is working correctly but just tailing your application logs and verify every 5 minutes you get a request.</p>
<p>You can also run </p>
<pre name="code" class="console">
 passenger-status
</pre>
<p>You should see at least the count variable to be at least 1 instance.</p>
<p>Note, this workaround will not immediate start up an instance upon restart.  You can add an initial request as part of your post deploy capistrano task though.  You probably should be making sure your application is up after deploying or restarting the application anyways.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/12/07/rails-initial-request-slow-with-mod-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Where is my sequel sock?</title>
		<link>http://www.theodorenguyen-cao.com/2008/05/03/where-is-my-sequel-sock/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/05/03/where-is-my-sequel-sock/#comments</comments>
		<pubDate>Sat, 03 May 2008 05:33:40 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/05/03/where-is-my-sequel-sock/</guid>
		<description><![CDATA[I was looking for where mysql.sock was since running rake db:bootstrap was complaining with &#8220;No such file or directory &#8211; /tmp/mysql.sock&#8221;. Rails looks for the mysql.sock file under /tmp/mysql.sock by default. Ubuntu using an apt-get install of mysql puts the mysql.sock file at /var/run/mysqld/mysqld.sock. I always forget where it is. So, I&#8217;m writing it down. [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for where mysql.sock was since running rake db:bootstrap was complaining with &#8220;No such file or directory &#8211; /tmp/mysql.sock&#8221;.  Rails looks for the mysql.sock file under /tmp/mysql.sock by default.  Ubuntu using an apt-get install of mysql puts the mysql.sock file at /var/run/mysqld/mysqld.sock.</p>
<p>I always forget where it is. So, I&#8217;m writing it down.</p>
<p><strong>/var/run/mysqld/mysqld.sock</strong></p>
<p>You can also grep for it from mysql like so</p>
<pre class="console">
&gt;&gt;  mysql -? | grep mysqld.sock
socket                            /var/run/mysqld/mysqld.sock</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/05/03/where-is-my-sequel-sock/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ubuntu upgrade broke WordPress</title>
		<link>http://www.theodorenguyen-cao.com/2008/04/28/ubuntu-upgrade-broke-wordpress/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/04/28/ubuntu-upgrade-broke-wordpress/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 04:42:01 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/04/28/ubuntu-upgrade-broke-wordpress/</guid>
		<description><![CDATA[Something with my past two Ubuntu upgrades broke all the internal links on my blog running on WordPress. It turns out the upgrade process changed the name of the target link on the .htaccess symbolic link file under my WordPress install directory. After the install this is what was linked: .htaccess -&#62; /etc/wordpress/htaccess Notice the [...]]]></description>
			<content:encoded><![CDATA[<p>Something with my past two Ubuntu upgrades broke all the internal links on my blog running on WordPress.</p>
<p>It turns out the upgrade process changed the name of the target link on the .htaccess symbolic link file under my WordPress install directory.</p>
<p>After the install this is what was linked:</p>
<pre class="console">.htaccess -&gt; /etc/wordpress/htaccess</pre>
<p>Notice the missing &#8220;.&#8221; in .htaccess.</p>
<p>To fix it, I had to update the link to with</p>
<pre class="console"> &gt;&gt; ln -sf /etc/wordpress/.htaccess .htaccess</pre>
<p>All the links work again!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/04/28/ubuntu-upgrade-broke-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Top 8 Unix Commands for the Developer</title>
		<link>http://www.theodorenguyen-cao.com/2008/01/31/top-8-unix-commands-for-the-developer/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/01/31/top-8-unix-commands-for-the-developer/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 00:56:43 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[unix]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/01/31/top-8-unix-commands-for-the-developer/</guid>
		<description><![CDATA[As a developer, there are certain UNIX commands you find yourself typing repeatedly. Whether it&#8217;s to debug a production issue or just modifying some files, these commands have helped me do my job time and time again. Here&#8217;s my top 8: grep &#8211; Prints the lines that match the pattern provided in the files specified [...]]]></description>
			<content:encoded><![CDATA[<p>As a developer, there are certain UNIX commands you find yourself typing repeatedly.  Whether it&#8217;s to debug a production issue or just modifying some files, these commands have helped me do my job time and time again.  Here&#8217;s my top 8:</p>
<ol>
<li>grep &#8211; Prints the lines that match the pattern provided in the files specified
<ul>
<li>Usage:  <code>grep &lt;options&gt; &lt;pattern&gt; &lt;files&gt;</code></li>
<li>Example: <code>grep -n Exception production.log</code>
<ul>
<li>Prints all the line (showing line numbers) in the file <code>production.log</code> that contain the string &#8216;Exception&#8217;</li>
</ul>
</li>
</ul>
</li>
<li>tail &#8211; Only interested in a the last couple of lines in a file? tail allows you to quickly view the end of the file
<ul>
<li>Usage: <code>tail &lt;options&gt; &lt;file&gt;</code></li>
<li>Example: <code>tail -fn100 production.log</code>
<ul>
<li>Shows the last 100 lines of the log and waits to display any new text appended to the file</li>
</ul>
</li>
</ul>
</li>
<li>ssh &#8211; Log into remote servers
<ul>
<li>Usage: <code>ssh -p&lt;port&gt; &lt;username&gt;@&lt;hostname&gt;</code></li>
<li>Example: <code>ssh -p1234 theo@production</code>
<ul>
<li>Logs into  the server named production on port 1234</li>
</ul>
</li>
</ul>
</li>
<li>scp &#8211; Copies files to/from remote servers
<ul>
<li>Usage: <code>scp -P&lt;port&gt; &lt;source&gt; &lt;target&gt;</code></li>
<li> Example: <code>scp -P1234 /home/theo/myfile.txt production@/home/jsmith</code>
<ul>
<li>Copies <code>myfile.txt</code> from <code>/home/theo</code> to the server named production under  <code>/home/jsmith</code></li>
</ul>
</li>
</ul>
</li>
<li>rm &#8211; Deletes stuff!
<ul>
<li>Usage: <code>rm &lt;options&gt; &lt;file&gt;</code></li>
<li>Example: <code>rm -rf mydir</code>
<ul>
<li>Removes  the entire directory and files with no prompt for confirmation (Use with caution!)</li>
</ul>
</li>
</ul>
</li>
<li>ps &#8211; Shows process status
<ul>
<li>Usage: <code>ps &lt;options&gt;</code></li>
<li>Example: <code>ps aux</code>
<ul>
<li>Displays the process status of processes for all users including those that are controlled by a terminal (system processes) sorted by CPU usage</li>
</ul>
</li>
</ul>
</li>
<li>top &#8211; Similar to ps but it periodically updates the information such as CPU and memory usage
<ul>
<li>Usage: top</li>
<li>Example: top (duh!)</li>
</ul>
</li>
<li>kill &#8211; terminates a process
<ul>
<li>Usage: kill &lt;option&gt; &lt;pid&gt;</li>
<li>Example: kill -9  12345
<ul>
<li>Terminates the process with id of 12345 using a non-catchable, non-ignorable signal (that just means you REALLY mean to kill it)</li>
</ul>
</li>
</ul>
</li>
</ol>
<p>I use lots of these commands in combination. For example, if tomcat seems to hang and won&#8217;t properly shut down I would do the following:</p>
<pre class="console">
  &gt;&gt; ps aux | grep tomcat</pre>
<p>I would then take the pid of tomcat and run:</p>
<pre class="console">
  &gt;&gt; kill -9 &lt;tomcat-pid&gt;</pre>
<p>Now you may be wondering why the &#8220;Top 8&#8243;, why not &#8220;Top 10&#8243;.  Well, because 8 is the new 10 and those are all UNIX commands I know <img src='http://www.theodorenguyen-cao.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>What are some of the commands that you use to get through the day?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/01/31/top-8-unix-commands-for-the-developer/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
