This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
/
deploy.rb
76 lines (61 loc) · 2.36 KB
/
deploy.rb
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
73
74
75
76
# frozen_string_literal: true
include_recipe 'opsworks_ruby::configure'
every_enabled_application do |application, deploy|
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.before_deploy(self)
end
scm = Drivers::Scm::Factory.build(application, node)
framework = Drivers::Framework::Factory.build(application, node)
appserver = Drivers::Appserver::Factory.build(application, node)
webserver = Drivers::Webserver::Factory.build(application, node)
scm.before_deploy(self)
framework.before_deploy(self)
appserver.before_deploy(self)
webserver.before_deploy(self)
deploy application['shortname'] do
deploy_to deploy_dir(application)
user node['deployer']['user'] || 'root'
group www_group
rollback_on_error true
environment framework.out[:deploy_environment]
create_dirs_before_symlink deploy[:create_dirs_before_symlink]
keep_releases deploy[:keep_releases]
purge_before_symlink deploy[:purge_before_symlink] if deploy[:purge_before_symlink]
symlink_before_migrate deploy[:symlink_before_migrate]
symlinks deploy[:symlinks] if deploy[:symlinks]
scm.out.each do |scm_key, scm_value|
send(scm_key, scm_value)
end
appserver.notifies[:deploy].each do |config|
notifies config[:action],
config[:resource].respond_to?(:call) ? config[:resource].call(application) : config[:resource],
config[:timer]
end
migration_command(framework.out[:migration_command])
migrate framework.out[:migrate]
before_migrate do
perform_bundle_install(release_path)
run_callback_from_file(File.join(release_path, 'deploy', 'before_migrate.rb'))
end
before_symlink do
perform_bundle_install(release_path) unless framework.out[:migrate]
run_callback_from_file(File.join(release_path, 'deploy', 'before_symlink.rb'))
end
before_restart do
directory File.join(release_path, '.git') do
recursive true
action :delete
end
run_callback_from_file(File.join(release_path, 'deploy', 'before_restart.rb'))
end
end
webserver.after_deploy(self)
appserver.after_deploy(self)
framework.after_deploy(self)
scm.after_deploy(self)
every_enabled_rds do |rds|
database = Drivers::Db::Factory.build(application, node, rds: rds)
database.after_deploy(self)
end
end