15964: Remove qr1hi from a few more places. Delete unused includes.
[arvados.git] / services / api / bin / setup
1 #!/usr/bin/env ruby
2
3 # Copyright (C) The Arvados Authors. All rights reserved.
4 #
5 # SPDX-License-Identifier: AGPL-3.0
6
7 require 'pathname'
8 require 'fileutils'
9 include FileUtils
10
11 # path to your application root.
12 APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
13
14 def system!(*args)
15   system(*args) || abort("\n== Command #{args} failed ==")
16 end
17
18 chdir APP_ROOT do
19   # This script is a starting point to setup your application.
20   # Add necessary setup steps to this file.
21
22   puts '== Installing dependencies =='
23   system! 'gem install bundler --conservative'
24   system('bundle check') || system!('bundle install')
25
26   # puts "\n== Copying sample files =="
27   # unless File.exist?('config/database.yml')
28   #   cp 'config/database.yml.sample', 'config/database.yml'
29   # end
30
31   puts "\n== Preparing database =="
32   system! 'bin/rails db:setup'
33
34   puts "\n== Removing old logs and tempfiles =="
35   system! 'bin/rails log:clear tmp:clear'
36
37   puts "\n== Restarting application server =="
38   system! 'bin/rails restart'
39 end