Merge branch '15964-fix-docs' refs #15964
[arvados.git] / services / api / bin / update
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 'fileutils'
8 include FileUtils
9
10 # path to your application root.
11 APP_ROOT = File.expand_path('..', __dir__)
12
13 def system!(*args)
14   system(*args) || abort("\n== Command #{args} failed ==")
15 end
16
17 chdir APP_ROOT do
18   # This script is a way to update your development environment automatically.
19   # Add necessary update steps to this file.
20
21   puts '== Installing dependencies =='
22   system! 'gem install bundler --conservative'
23   system('bundle check') || system!('bundle install')
24
25   puts "\n== Updating database =="
26   system! 'bin/rails db:migrate'
27
28   puts "\n== Removing old logs and tempfiles =="
29   system! 'bin/rails log:clear tmp:clear'
30
31   puts "\n== Restarting application server =="
32   system! 'bin/rails restart'
33 end