<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tommy Lee</title>
    <description>The latest articles on DEV Community by Tommy Lee (@tomcentrate).</description>
    <link>https://dev.to/tomcentrate</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F17086%2F6af9a756-3327-46ef-aea5-a7777b20b0f0.jpeg</url>
      <title>DEV Community: Tommy Lee</title>
      <link>https://dev.to/tomcentrate</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tomcentrate"/>
    <language>en</language>
    <item>
      <title>Fixing Hot Reloads on Vagrant</title>
      <dc:creator>Tommy Lee</dc:creator>
      <pubDate>Thu, 20 Apr 2017 04:15:22 +0000</pubDate>
      <link>https://dev.to/tomcentrate/fixing-hot-reloads-on-vagrant</link>
      <guid>https://dev.to/tomcentrate/fixing-hot-reloads-on-vagrant</guid>
      <description>

&lt;p&gt;One of the common issues that I've run into virtualizing my development environments is having to restart my server manually.&lt;/p&gt;

&lt;p&gt;Whenever I developed locally, everything was fast, and changes appeared on first refresh. But when I used a VM, the frustration of restarting the server killed a lot of my productivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Issue
&lt;/h2&gt;

&lt;p&gt;Many of the hot reloads rely on detecting when the file has changed in your directory. Usually, we have something that watches the directory, and listens for a change. &lt;/p&gt;

&lt;p&gt;Whenever a file is changed, the system kernel emits a notification letting a program know that something changed. In Linux systems, we have &lt;code&gt;inotify&lt;/code&gt;, on OSX, it's &lt;code&gt;fsevents&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Since we're using a virtual machine, our program is only listening to notifications emitted on the virtual machine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution 1: Forward File Change Events
&lt;/h2&gt;

&lt;p&gt;A recommended solution is to add a vagrant plugin to take care of forwarding file events to the VM. &lt;/p&gt;

&lt;p&gt;Currently we're using &lt;a href="https://github.com/adrienkohlbecker/vagrant-fsnotify"&gt;vagrant-fsnotify&lt;/a&gt; to forward events.&lt;/p&gt;

&lt;p&gt;After installing the plugin we.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;add the fsnotify:true to our synced file directory.&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;   &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;vm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;synced_folder&lt;/span&gt; &lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"/vagrant"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;fsnotify: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Restart the machine&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Start &lt;code&gt;vagrant fsnotify&lt;/code&gt; in a separate tab.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;   vagrant fsnotify
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution 2: Polling
&lt;/h2&gt;

&lt;p&gt;An older recommendation is to switch to &lt;em&gt;polling&lt;/em&gt;, which detects changes to the modification date occasionally. This was Ruby on Rails' default detection method until version 4. &lt;/p&gt;

&lt;p&gt;This is a fallback in cases where file event updates aren't available. You can check your dev-server's start system options, and see if a polling option exists.&lt;/p&gt;

&lt;p&gt;I don't recommend this, since polling takes up more memory and CPU, but if inotify forwarding is unavailable:&lt;/p&gt;

&lt;p&gt;In this &lt;a href="http://stackoverflow.com/questions/33681004/webpack-dev-server-reload-doesnt-work-on-virtual-box/33699702"&gt;stackoverflow post&lt;/a&gt;, they enabled polling via &lt;code&gt;vagrant rsync-auto&lt;/code&gt;.&lt;/p&gt;


</description>
      <category>vagrant</category>
      <category>devenvironment</category>
      <category>fsevents</category>
    </item>
    <item>
      <title>Hi, I'm Tommy Lee</title>
      <dc:creator>Tommy Lee</dc:creator>
      <pubDate>Thu, 20 Apr 2017 04:07:18 +0000</pubDate>
      <link>https://dev.to/tomcentrate/hi-im-tommy-lee</link>
      <guid>https://dev.to/tomcentrate/hi-im-tommy-lee</guid>
      <description>&lt;p&gt;I have been coding for 6 years.&lt;/p&gt;

&lt;p&gt;You can find me on GitHub as &lt;a href="https://github.com/tomcentrate" rel="noopener noreferrer"&gt;tomcentrate&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Orlando, FL.&lt;/p&gt;

&lt;p&gt;I work for Fresh Lines&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: Ruby, PHP, Javascript, SQL.&lt;/p&gt;

&lt;p&gt;I am currently learning more about Go, Elixir, Node.js.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
