summaryrefslogtreecommitdiffstats
path: root/config/deploy.rb
blob: 9456fef50909e2ae16103c1dcd57a497c0dcac5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# config valid only for current version of Capistrano
lock '3.6.0'

set :application, 'registration'
set :repo_url, 'https://github.com/snake66/norsk-urskog-registrations.git'
set :deploy_to, '/usr/home/norskurskog/www/registration'
set :linked_files, fetch(:linked_files, []).push('config.yml')

# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('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

  before 'check:linked_files', :upload_config => 'config.yml' do |t|
    on roles(:app) do
      shared_dir = File.join(fetch(:deploy_to), 'shared')
      upload!(t.prerequisites.first, File.join(shared_dir, t.prerequisites.first))
    end
  end

  file 'nu_regform' do |f|
    template = IO.read('config/deploy/templates/thinrc.erb')
    res = ERB.new(template).result(binding)
    IO.write(t.name, res)
  end

  #after :updated, :upload_init_script => 'nu_regform' do |t|
  #  on roles(:app) do
  #    shared_dir = File.join(fetch(:deploy_to), 'shared')
  #    upload!(t.prerequisites.first, File.join(shared_dir, t.prerequisites.first))
  #  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