Read about our upcoming Code of Conduct on this issue

setup 957 Bytes
Newer Older
Valery Sizov's avatar
Valery Sizov committed
1
#!/usr/bin/env ruby
Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
2
3
require 'fileutils'
include FileUtils
Valery Sizov's avatar
Valery Sizov committed
4
5

# path to your application root.
Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
6
APP_ROOT = File.expand_path('..', __dir__)
7

8
9
def system!(*args)
  system(*args) || abort("\n== Command #{args} failed ==")
10
end
Valery Sizov's avatar
Valery Sizov committed
11

Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
12
13
14
15
16
17
18
chdir APP_ROOT do
  # This script is a starting point to setup your application.
  # Add necessary setup steps to this file.

  puts '== Installing dependencies =='
  system! 'gem install bundler --conservative'
  system('bundle check') || system!('bundle install')
Valery Sizov's avatar
Valery Sizov committed
19

Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
20
21
  # Install JavaScript dependencies if using Yarn
  # system('bin/yarn')
Valery Sizov's avatar
Valery Sizov committed
22
23

  # puts "\n== Copying sample files =="
Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
24
25
  # unless File.exist?('config/database.yml')
  #   cp 'config/database.yml.sample', 'config/database.yml'
Valery Sizov's avatar
Valery Sizov committed
26
27
28
  # end

  puts "\n== Preparing database =="
Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
29
  system! 'bin/rails db:setup'
Valery Sizov's avatar
Valery Sizov committed
30
31

  puts "\n== Removing old logs and tempfiles =="
Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
32
  system! 'bin/rails log:clear tmp:clear'
Valery Sizov's avatar
Valery Sizov committed
33
34

  puts "\n== Restarting application server =="
Heinrich Lee Yu's avatar
Heinrich Lee Yu committed
35
  system! 'bin/rails restart'
Valery Sizov's avatar
Valery Sizov committed
36
end