Class: Appsignal::Capistrano Private

Inherits:
Object
  • Object
show all
Defined in:
lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

TODO:

Move to sub-namespace

Class Method Summary collapse

Class Method Details

.tasks(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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
# File 'lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb', line 7

def self.tasks(config)
  config.load do # rubocop:disable Metrics/BlockLength
    after "deploy", "appsignal:deploy"
    after "deploy:migrations", "appsignal:deploy"

    namespace :appsignal do
      task :deploy do
        env = fetch(:appsignal_env, fetch(:stage, fetch(:rails_env, fetch(:rack_env, "production"))))
        user = fetch(:appsignal_user, ENV["USER"] || ENV["USERNAME"])
        revision = fetch(:appsignal_revision, fetch(:current_revision))

        appsignal_config = Appsignal::Config.new(
          ENV["PWD"],
          env,
          {},
          Appsignal::Utils::IntegrationLogger.new(StringIO.new)
        ).tap do |c|
          fetch(:appsignal_config, {}).each do |key, value|
            c[key] = value
          end
          c.validate
        end

        if appsignal_config && appsignal_config.active?
          marker_data = {
            :revision => revision,
            :user => user
          }

          marker = Marker.new(marker_data, appsignal_config)
          if config.dry_run
            puts "Dry run: AppSignal deploy marker not actually sent."
          else
            marker.transmit
          end
        else
          puts "Not notifying of deploy, config is not active for environment: #{env}"
        end
      end
    end
  end
end