| 
42
 | 
     1 #!/usr/bin/env ruby
 | 
| 
214
 | 
     2 require "fileutils"
 | 
| 
42
 | 
     3 
 | 
| 
 | 
     4 # path to your application root.
 | 
| 
223
 | 
     5 APP_ROOT = File.expand_path("..", __dir__)
 | 
| 
42
 | 
     6 
 | 
| 
72
 | 
     7 def system!(*args)
 | 
| 
 | 
     8   system(*args) || abort("\n== Command #{args} failed ==")
 | 
| 
 | 
     9 end
 | 
| 
 | 
    10 
 | 
| 
185
 | 
    11 FileUtils.chdir APP_ROOT do
 | 
| 
214
 | 
    12   # This script is a way to set up or update your development environment automatically.
 | 
| 
 | 
    13   # This script is idempotent, so that you can run it at any time and get an expectable outcome.
 | 
| 
72
 | 
    14   # Add necessary setup steps to this file.
 | 
| 
42
 | 
    15 
 | 
| 
223
 | 
    16   puts "== Installing dependencies =="
 | 
| 
 | 
    17   system! "gem install bundler --conservative"
 | 
| 
 | 
    18   system("bundle check") || system!("bundle install")
 | 
| 
42
 | 
    19 
 | 
| 
 | 
    20   puts "\n== Removing old logs and tempfiles =="
 | 
| 
223
 | 
    21   system! "bin/rails log:clear tmp:clear"
 | 
| 
42
 | 
    22 
 | 
| 
 | 
    23   puts "\n== Restarting application server =="
 | 
| 
223
 | 
    24   system! "bin/rails restart"
 | 
| 
42
 | 
    25 end
 |