Skip to content
Snippets Groups Projects
setup 946 B
Newer Older
  • Learn to ignore specific revisions
  • Eugen Rochko's avatar
    Eugen Rochko committed
    #!/usr/bin/env ruby
    require 'pathname'
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    require 'fileutils'
    include FileUtils
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    
    # path to your application root.
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    def system!(*args)
      system(*args) || abort("\n== Command #{args} failed ==")
    end
    
    chdir APP_ROOT do
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      # This script is a starting point to setup your application.
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      # Add necessary setup steps to this file.
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      puts '== Installing dependencies =='
      system! 'gem install bundler --conservative'
      system('bundle check') || system!('bundle install')
    
      system!('yarn install')
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    
      # puts "\n== Copying sample files =="
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      # unless File.exist?('config/database.yml')
      #   cp 'config/database.yml.sample', 'config/database.yml'
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      # end
    
      puts "\n== Preparing database =="
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      system! 'bin/rails db:setup'
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    
      puts "\n== Removing old logs and tempfiles =="
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      system! 'bin/rails log:clear tmp:clear'
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    
      puts "\n== Restarting application server =="
    
    Eugen Rochko's avatar
    Eugen Rochko committed
      system! 'bin/rails restart'
    
    Eugen Rochko's avatar
    Eugen Rochko committed
    end