Commit b901ab34e7d0c7a55ac7784a9cea9e2303e339e5
1 parent
224cad0f
Exists in
colab
and in
4 other branches
Update setup
Showing
1 changed file
with
29 additions
and
15 deletions
Show diff stats
| 1 | 1 | #!/usr/bin/env ruby |
| 2 | 2 | require 'pathname' |
| 3 | +require 'colorize' | |
| 4 | + | |
| 5 | +def run(command) | |
| 6 | + system(command) | |
| 7 | + unless $?.exitstatus.zero? | |
| 8 | + puts "Command #{command} exited with nonzero status".red | |
| 9 | + exit 1 | |
| 10 | + end | |
| 11 | +end | |
| 3 | 12 | |
| 4 | 13 | # path to your application root. |
| 5 | 14 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) |
| ... | ... | @@ -8,22 +17,27 @@ Dir.chdir APP_ROOT do |
| 8 | 17 | # This script is a starting point to setup your application. |
| 9 | 18 | # Add necessary setup steps to this file: |
| 10 | 19 | |
| 11 | - puts "== Installing dependencies ==" | |
| 12 | - system "gem install bundler --conservative" | |
| 13 | - system "bundle check || bundle install" | |
| 20 | + puts "== Installing dependencies ==".green | |
| 21 | + run "gem install bundler --conservative" | |
| 22 | + run "bundle check || bundle install" | |
| 14 | 23 | |
| 15 | - # puts "\n== Copying sample files ==" | |
| 16 | - # unless File.exist?("config/database.yml") | |
| 17 | - # system "cp config/database.yml.sample config/database.yml" | |
| 18 | - # end | |
| 24 | + puts "\n== Copying sample files ==".green | |
| 25 | + unless File.exist?("config/database.yml") | |
| 26 | + run "cp config/database.yml.sample config/database.yml" | |
| 27 | + end | |
| 19 | 28 | |
| 20 | - puts "\n== Preparing database ==" | |
| 21 | - system "bin/rake db:setup" | |
| 29 | + puts "\n== Preparing database ==".green | |
| 30 | + puts "\n== Create database ==".yellow | |
| 31 | + run "bin/rake db:create" | |
| 32 | + puts "\n== Run migrations ==".yellow | |
| 33 | + run "bin/rake db:migrate" | |
| 34 | + puts "\n== Run seeds (may fail if the Kalibro Configurations Service is not up and running) ==".yellow | |
| 35 | + run "bin/rake db:seed" | |
| 22 | 36 | |
| 23 | - puts "\n== Removing old logs and tempfiles ==" | |
| 24 | - system "rm -f log/*" | |
| 25 | - system "rm -rf tmp/cache" | |
| 37 | + puts "\n== Removing old logs and tempfiles ==".green | |
| 38 | + run 'bin/rake log:clear' | |
| 39 | + run 'bin/rake tmp:clear' | |
| 26 | 40 | |
| 27 | - puts "\n== Restarting application server ==" | |
| 28 | - system "touch tmp/restart.txt" | |
| 29 | -end | |
| 30 | 41 | \ No newline at end of file |
| 42 | + puts "\n== Restarting application server ==".green | |
| 43 | + run "touch tmp/restart.txt" | |
| 44 | +end | ... | ... |