Commit bed500090e3cfe7a9e42e540cc2b8407b4ffcfc5
1 parent
6bc9249b
Exists in
master
and in
4 other branches
Capistrano deployment example scripts
Showing
2 changed files
with
76 additions
and
0 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, 'gitlab' | ||
| 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 |