Commit 9c2a6e201388e7e30987a8679ddfa65b9422a38c
Exists in
master
and in
4 other branches
Merge pull request #3047 from mikew/capistrano-deploy-example
Capistrano deploy example
Showing
3 changed files
with
82 additions
and
4 deletions
Show diff stats
@@ -0,0 +1,72 @@ | @@ -0,0 +1,72 @@ | ||
1 | +set :domain, 'set application domain here' | ||
2 | +set :db_adapter, 'mysql' # or postgres | ||
3 | +set :mount_point, '/' | ||
4 | +set :application, 'gitlabhq' | ||
5 | +set :user, 'git' | ||
6 | +set :rails_env, 'production' | ||
7 | +set :deploy_to, "/home/#{user}/apps/#{application}" | ||
8 | +set :bundle_without, %w[development test] + (%w[mysql postgres] - [db_adapter]) | ||
9 | +set :asset_env, "RAILS_GROUPS=assets RAILS_RELATIVE_URL_ROOT=#{mount_point.sub /\/+\Z/, ''}" | ||
10 | + | ||
11 | +set :use_sudo, false | ||
12 | +default_run_options[:pty] = true | ||
13 | + | ||
14 | +# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` | ||
15 | +set :scm, :git | ||
16 | +set :repository, "git@#{domain}:#{application}.git" | ||
17 | +set :deploy_via, :remote_cache | ||
18 | + | ||
19 | +# Alternatively, you can deploy via copy, if you don't have gitlab in git | ||
20 | +#set :scm, :none | ||
21 | +#set :repository, '.' | ||
22 | +#set :deploy_via, :copy | ||
23 | + | ||
24 | +server domain, :app, :web, :db, primary: true | ||
25 | + | ||
26 | +namespace :foreman do | ||
27 | + desc 'Export the Procfile to Ubuntu upstart scripts' | ||
28 | + task :export, roles: :app do | ||
29 | + foreman_export = "foreman export upstart /etc/init -f Procfile -a #{application} -u #{user} -l #{shared_path}/log/foreman" | ||
30 | + run "cd #{release_path} && #{sudo} #{fetch :bundle_cmd, 'bundle'} exec #{foreman_export}" | ||
31 | + end | ||
32 | + | ||
33 | + desc 'Start the application services' | ||
34 | + task :start, roles: :app do | ||
35 | + run "#{sudo} service #{application} start" | ||
36 | + end | ||
37 | + | ||
38 | + desc 'Stop the application services' | ||
39 | + task :stop, roles: :app do | ||
40 | + run "#{sudo} service #{application} stop" | ||
41 | + end | ||
42 | + | ||
43 | + desc 'Restart the application services' | ||
44 | + task :restart, roles: :app do | ||
45 | + run "#{sudo} service #{application} restart" | ||
46 | + end | ||
47 | +end | ||
48 | + | ||
49 | +namespace :deploy do | ||
50 | + desc 'Start the application services' | ||
51 | + task :start, roles: :app do | ||
52 | + foreman.start | ||
53 | + end | ||
54 | + | ||
55 | + desc 'Stop the application services' | ||
56 | + task :stop, roles: :app do | ||
57 | + foreman.stop | ||
58 | + end | ||
59 | + | ||
60 | + desc 'Restart the application services' | ||
61 | + task :restart, roles: :app do | ||
62 | + foreman.restart | ||
63 | + end | ||
64 | +end | ||
65 | + | ||
66 | +after 'deploy:cold' do | ||
67 | + run "cd #{release_path} && #{rake} gitlab:setup force=yes RAILS_ENV=#{rails_env}" | ||
68 | + deploy.restart | ||
69 | +end | ||
70 | + | ||
71 | +after 'deploy:update', 'foreman:export' # Export foreman scripts | ||
72 | +#after 'deploy:update', 'foreman:restart' # Restart application scripts |
lib/tasks/gitlab/setup.rake
@@ -7,10 +7,12 @@ namespace :gitlab do | @@ -7,10 +7,12 @@ namespace :gitlab do | ||
7 | def setup_db | 7 | def setup_db |
8 | warn_user_is_not_gitlab | 8 | warn_user_is_not_gitlab |
9 | 9 | ||
10 | - puts "This will create the necessary database tables and seed the database." | ||
11 | - puts "You will lose any previous data stored in the database." | ||
12 | - ask_to_continue | ||
13 | - puts "" | 10 | + unless ENV['force'] == 'yes' |
11 | + puts "This will create the necessary database tables and seed the database." | ||
12 | + puts "You will lose any previous data stored in the database." | ||
13 | + ask_to_continue | ||
14 | + puts "" | ||
15 | + end | ||
14 | 16 | ||
15 | Rake::Task["db:setup"].invoke | 17 | Rake::Task["db:setup"].invoke |
16 | Rake::Task["db:seed_fu"].invoke | 18 | Rake::Task["db:seed_fu"].invoke |