summaryrefslogtreecommitdiff
path: root/config/deploy.rb.example
blob: ddce4671b58e38f50a4faf6de9393bb62fbe5e28 (plain)
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
63
64
65
66
67
68
69
70
71
72
set :domain,         'set application domain here'
set :db_adapter,     'mysql' # or postgres
set :mount_point,    '/'
set :application,    'gitlabhq'
set :user,           'git'
set :rails_env,      'production'
set :deploy_to,      "/home/#{user}/apps/#{application}"
set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter])
set :asset_env,      "RAILS_GROUPS=assets RAILS_RELATIVE_URL_ROOT=#{mount_point.sub /\/+\Z/, ''}"

set :use_sudo, false
default_run_options[:pty] = true

# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :scm,        :git
set :repository, "git@#{domain}:#{application}.git"
set :deploy_via, :remote_cache

# Alternatively, you can deploy via copy, if you don't have gitlab in git
#set :scm, :none
#set :repository, '.'
#set :deploy_via, :copy

server domain, :app, :web, :db, primary: true

namespace :foreman do
  desc 'Export the Procfile to Ubuntu upstart scripts'
  task :export, roles: :app do
    foreman_export = "foreman export upstart /etc/init -f Procfile -a #{application} -u #{user} -l #{shared_path}/log/foreman"
    run "cd #{release_path} && #{sudo} #{fetch :bundle_cmd, 'bundle'} exec #{foreman_export}"
  end

  desc 'Start the application services'
  task :start, roles: :app do
    run "#{sudo} service #{application} start"
  end

  desc 'Stop the application services'
  task :stop, roles: :app do
    run "#{sudo} service #{application} stop"
  end

  desc 'Restart the application services'
  task :restart, roles: :app do
    run "#{sudo} service #{application} restart"
  end
end

namespace :deploy do
  desc 'Start the application services'
  task :start, roles: :app do
    foreman.start
  end

  desc 'Stop the application services'
  task :stop, roles: :app do
    foreman.stop
  end

  desc 'Restart the application services'
  task :restart, roles: :app do
    foreman.restart
  end
end

after 'deploy:cold' do
  run "cd #{release_path} && #{rake} gitlab:setup force=yes RAILS_ENV=#{rails_env}"
  deploy.restart
end

after 'deploy:update', 'foreman:export'  # Export foreman scripts
#after 'deploy:update', 'foreman:restart' # Restart application scripts