Method: Sunshine::App#deploy

Defined in:
lib/sunshine/app.rb

#deploy(options = nil) ⇒ Object

Deploy the application to deploy servers and call user’s post-deploy code. Supports any App#find options.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/sunshine/app.rb', line 130

def deploy options=nil
  Sunshine.logger.info :app, "Beginning deploy of #{@name}" do
    connect options
  end

  deploy_trap = Sunshine.add_trap "Reverting deploy of #{@name}" do
    revert! options
  end

  with_filter options do |app|
    make_app_directories
    checkout_codebase
    symlink_current_dir

    yield(self) if block_given?

    run_post_user_lambdas

    health :enable

    build_control_scripts
    build_deploy_info_file
    build_crontab

    register_as_deployed
    remove_old_deploys
  end

rescue => e
  message = "#{e.class}: #{e.message}"

  Sunshine.logger.error :app, message do
    Sunshine.logger.error '>>', e.backtrace.join("\n")
    revert!
  end

ensure
  Sunshine.delete_trap deploy_trap

  Sunshine.logger.info :app, "Ending deploy of #{@name}" do
    disconnect options
  end
end