lcreid / rails-5-jade

Rails 5 with Jekyll and Node on Ubuntu 18.04
MIT License
29 stars 3 forks source link

Clock on box drifts #15

Closed lcreid closed 7 years ago

lcreid commented 7 years ago

The clock on the rails5 box drifts from real time. Perhaps this is because I haven't set up NTP for it.

I wonder if this is what causes the problem that we've observed that long-running boxes lose the ability to automatically identify when files have changed?

lcreid commented 7 years ago

Ubuntu 16.04 (at least) has a new time synchronization method, timedatectl and timesyncd. When I do systemctl status systemd-timesyncd, I get:

● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: inactive (dead)
Condition: start condition failed at Sun 2016-10-23 17:50:59 PDT; 1 weeks 0 days ago
           ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met
     Docs: man:systemd-timesyncd.service(8)
lcreid commented 7 years ago

Text I used to have in the readme:

Time synchronization on the Vagrant box seems to fail sometimes. This can lead to Rails not recognizing changes to files, so you'll fix something, but Rails won't reload the changed file, and you'll think your change didn't do anything. This may happen after suspending and resuming the Vagrant box, for example, if your host is a laptop and it goes to sleep.

You can set the time to sync by entering this in the Vagrant box:

sudo VBoxService --timesync-set-start

I tried a more permanent solution, but I haven't used it long enough to know if it works. First, get the name of the Vagrant box by entering this on the host:

VBoxManage list vms

Then enter this on the host:

VBoxManage guestproperty set guest_machine_name --timesync-set-on-restore 1
lcreid commented 7 years ago

I set the --timesync-set-on-restore 1 parameter in the template.json for the Packer build.