summaryrefslogblamecommitdiffstats
path: root/config/deploy.rb
blob: bd5965cdc391d6fafd5d7aceb5c80b2932e48146 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                                     
             
 
                                
                                                                     
                                                        

                                                          

                                                    







                                                   











                                                     




                                                                              
                     




                                                            
         

       










                                                      
# config valid only for current version of Capistrano
lock '3.11.0'

set :application, 'registration'
set :repo_url, 'https://code.volse.no/norsk-urskog-registrations.git'
set :deploy_to, '/usr/home/norskurskog/www/registration'
append :linked_files, 'config.yml', '.env'
append :linked_dirs, 'public/uploads', 'bin', 'log', 'tmp'

set :bundle_binstubs, -> { shared_path.join('bin') }

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 5

namespace :deploy do
  file 'config.yml' do |f|
    template = "---\n"
             + "contact_email: contact@example.com\n"
             + "smtp:\n"
             + "  address: localhost\n"
             + "  port: 25\n"
             + "accept_registrations:\n"
             + "  start: YYYY.MM.DD\n"
             + "  stop: YYYY.MM.DD\n"
    IO.write(t.name, template)
  end

  file '.env' do |f|
    IO.write(t.name, "NUREG_BASE=/\n")
  end

  before 'check:linked_files', :upload_config => ['config.yml', '.env'] do |t|
    on roles(:app) do
      t.prerequisites.each do |r|
        target_file = File.join(fetch(:shared_directory), r)
        unless test("[ -f #{target_file} ]")
          upload!(t.prerequisites.first, target_file)
        end
      end
    end
  end

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end