If your local time is way off and you deploy with capistrano bad things can happen.
This task checks your local time before deploying. If it's > 1 second off it halts the deployment, tells you about the problem, and offers an easy way to fix it.
| before "deploy", "check_time" | |
| task :check_time do | |
| offset = `ntpdate -q ntp.ubuntu.com | tail -n 1 | awk -Foffset\ '{print $2}' | awk '{print $1}'`.strip | |
| if offset.to_f > 1.0 | |
| puts "Your clock is off by #{offset} seconds! Type `sudo ntpdate ntp.ubuntu.com` and try again." | |
| exit(1) | |
| end | |
| end |
If your local time is way off and you deploy with capistrano bad things can happen.
This task checks your local time before deploying. If it's > 1 second off it halts the deployment, tells you about the problem, and offers an easy way to fix it.