appsignal 2.4.3 → 2.5.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +14 -5
  3. data/.rubocop_todo.yml +3 -0
  4. data/.travis.yml +3 -4
  5. data/CHANGELOG.md +3 -0
  6. data/Rakefile +21 -6
  7. data/appsignal.gemspec +12 -5
  8. data/ext/Rakefile +27 -0
  9. data/ext/agent.yml +52 -21
  10. data/ext/base.rb +79 -0
  11. data/ext/extconf.rb +5 -76
  12. data/gemfiles/sequel-435.gemfile +5 -1
  13. data/gemfiles/sequel.gemfile +5 -1
  14. data/lib/appsignal.rb +11 -6
  15. data/lib/appsignal/cli.rb +1 -2
  16. data/lib/appsignal/cli/install.rb +3 -3
  17. data/lib/appsignal/config.rb +56 -37
  18. data/lib/appsignal/extension.rb +28 -4
  19. data/lib/appsignal/extension/jruby.rb +460 -0
  20. data/lib/appsignal/hooks/sidekiq.rb +4 -4
  21. data/lib/appsignal/integrations/capistrano/appsignal.cap +7 -2
  22. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +8 -3
  23. data/lib/appsignal/system.rb +16 -1
  24. data/lib/appsignal/transaction.rb +2 -2
  25. data/lib/appsignal/utils.rb +3 -1
  26. data/lib/appsignal/version.rb +1 -3
  27. data/spec/.rubocop.yml +3 -0
  28. data/spec/lib/appsignal/capistrano2_spec.rb +55 -41
  29. data/spec/lib/appsignal/capistrano3_spec.rb +87 -61
  30. data/spec/lib/appsignal/cli/diagnose_spec.rb +3 -3
  31. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +4 -4
  32. data/spec/lib/appsignal/config_spec.rb +54 -21
  33. data/spec/lib/appsignal/extension/jruby_spec.rb +43 -0
  34. data/spec/lib/appsignal/extension_spec.rb +28 -12
  35. data/spec/lib/appsignal/hooks/sequel_spec.rb +7 -1
  36. data/spec/lib/appsignal/integrations/que_spec.rb +5 -5
  37. data/spec/lib/appsignal/system_spec.rb +5 -4
  38. data/spec/lib/appsignal/transaction_spec.rb +8 -8
  39. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +4 -4
  40. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +3 -3
  41. data/spec/lib/appsignal_spec.rb +5 -3
  42. data/spec/spec_helper.rb +29 -8
  43. data/spec/support/helpers/config_helpers.rb +3 -2
  44. metadata +12 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4ab143f228d94a363e4689815fd535ce46f1a320847df9ed1cf307a1d98318a
4
- data.tar.gz: b0b7e3193dea2004e41550ed803cb1055f4a35f07a891c8d6857a63417917f4b
3
+ metadata.gz: aa4dc16e9ee1b853c9166e3c550e95820239d22fcf4be2bfbe908fff03681ce3
4
+ data.tar.gz: 980caa31b345676bb7964fa941f9aa0116195e28d933aac6ade62b2834006834
5
5
  SHA512:
6
- metadata.gz: a0c4da23abe2cffccc34e8ab9f0d5e9ef12d3512d878718ff3844ca27c37e44c3899361b28a6f038e56d127c734ce7b63b3151d4d91506d16b7909498a55b2ca
7
- data.tar.gz: 8fe67e9d23ffa026548c230fea7683cb0ac6f4651109901d0de2d1ec0857d792078ba45d825e8cb0169b8e5c916a8fdec3519fae6568d79c8551aee6639a22d4
6
+ metadata.gz: 99c6c3197f6d895731d8afb3bda5ed65cb38f1b0a1e9fe8a6b98f457429a0011f7f81bd1eab4ccf89e1bee8cf2448c168a50b8d00fd443c1a47e74f6a168b7f9
7
+ data.tar.gz: 49cfc74c9a975443b9b111c330e1b9b25600d6ac08c2a7c7037b46739af275f192f6b52e4ac5f713e622e795d5cbb285aff551b07035568e910033031645f019
@@ -11,6 +11,7 @@ AllCops:
11
11
  - "tmp/**/*"
12
12
  - "gemfiles/vendor/**/*"
13
13
  - "vendor/**/*"
14
+ - "benchmark.rake"
14
15
  DisplayCopNames: true
15
16
  UseCache: true
16
17
  CacheRootDirectory: ./tmp
@@ -24,22 +25,22 @@ Style/StringLiterals:
24
25
  Style/StringLiteralsInInterpolation:
25
26
  EnforcedStyle: double_quotes
26
27
 
27
- Style/AlignParameters:
28
+ Layout/AlignParameters:
28
29
  EnforcedStyle: with_fixed_indentation
29
30
 
30
- Style/MultilineMethodCallIndentation:
31
+ Layout/MultilineMethodCallIndentation:
31
32
  EnforcedStyle: indented
32
33
 
33
- Style/MultilineOperationIndentation:
34
+ Layout/MultilineOperationIndentation:
34
35
  EnforcedStyle: indented
35
36
 
36
37
  Style/HashSyntax:
37
38
  EnforcedStyle: hash_rockets
38
39
 
39
- Style/AlignHash:
40
+ Layout/AlignHash:
40
41
  EnforcedLastArgumentHashStyle: ignore_implicit
41
42
 
42
- Style/IndentArray:
43
+ Layout/IndentArray:
43
44
  EnforcedStyle: consistent
44
45
 
45
46
  Style/EmptyMethod:
@@ -53,5 +54,13 @@ Style/MethodMissing:
53
54
  Style/TrailingUnderscoreVariable:
54
55
  Enabled: false
55
56
 
57
+ Style/FileName:
58
+ Exclude:
59
+ - "ext/Rakefile"
60
+
61
+ Metrics/BlockLength:
62
+ Exclude:
63
+ - "Rakefile"
64
+
56
65
  # Metrics/LineLength:
57
66
  # Max: 80
@@ -119,3 +119,6 @@ Style/IfUnlessModifier:
119
119
  Style/NonNilCheck:
120
120
  Exclude:
121
121
  - 'lib/appsignal/transaction.rb'
122
+
123
+ Security/YAMLLoad:
124
+ Enabled: false
@@ -42,9 +42,6 @@ matrix:
42
42
  gemfile: "gemfiles/no_dependencies.gemfile"
43
43
  script: "bundle exec rubocop"
44
44
  exclude:
45
- # We don't currently support jRuby
46
- - rvm: "jruby-19mode"
47
-
48
45
  # Rails 5 doesn't support Ruby < 2.2
49
46
  - rvm: "2.0.0"
50
47
  gemfile: "gemfiles/rails-5.0.gemfile"
@@ -62,7 +59,9 @@ matrix:
62
59
  gemfile: "gemfiles/rails-4.1.gemfile"
63
60
 
64
61
  env:
65
- global: "RAILS_ENV=test"
62
+ global:
63
+ - "RAILS_ENV=test"
64
+ - "JRUBY_OPTS=''" # Workaround https://github.com/travis-ci/travis-ci/issues/6471
66
65
 
67
66
  before_install:
68
67
  - "gem update --system"
@@ -1,3 +1,6 @@
1
+ # 2.5.0 (Alpha)
2
+ * Add jRuby support. PR #376
3
+
1
4
  # 2.4.3
2
5
  * Store more details for Redis events. PR #374
3
6
 
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require "bundler"
2
+ require "fileutils"
2
3
 
3
- GEMFILES = %w(
4
+ GEMFILES = %w[
4
5
  capistrano2
5
6
  capistrano3
6
7
  grape
@@ -18,18 +19,18 @@ GEMFILES = %w(
18
19
  grape
19
20
  webmachine
20
21
  que
21
- ).freeze
22
+ ].freeze
22
23
 
23
- RUBY_VERSIONS = %w(
24
+ RUBY_VERSIONS = %w[
24
25
  2.0.0-p648
25
26
  2.1.8
26
27
  2.2.4
27
28
  2.3.0
28
29
  2.4.0
29
- ).freeze
30
+ ].freeze
30
31
 
31
32
  EXCLUSIONS = {
32
- "rails-5.0" => %w(2.0.0 2.1.8)
33
+ "rails-5.0" => %w[2.0.0 2.1.8]
33
34
  }.freeze
34
35
 
35
36
  VERSION_MANAGERS = {
@@ -48,6 +49,7 @@ task :publish do
48
49
 
49
50
  def build_and_push_gem
50
51
  puts "# Building gem"
52
+ FileUtils.rm_f("#{NAME}-#{gem_version}.gem")
51
53
  puts `gem build #{NAME}.gemspec`
52
54
  puts "# Publishing Gem"
53
55
  puts `gem push #{NAME}-#{gem_version}.gem`
@@ -93,7 +95,16 @@ task :publish do
93
95
  Appsignal.send(:remove_const, :VERSION)
94
96
  load File.expand_path(VERSION_FILE)
95
97
  system("$EDITOR #{CHANGELOG_FILE}")
98
+
99
+ # Build and push for MRI
100
+ ENV.delete("APPSIGNAL_PUSH_JAVA_GEM")
101
+ build_and_push_gem
102
+
103
+ # Build and push for jRuby
104
+ ENV["APPSIGNAL_PUSH_JAVA_GEM"] = "true"
96
105
  build_and_push_gem
106
+
107
+ # Create tag
97
108
  create_and_push_tag
98
109
  end
99
110
 
@@ -167,7 +178,11 @@ end
167
178
  namespace :extension do
168
179
  desc "Install the AppSignal gem extension"
169
180
  task :install => :clean do
170
- system "cd ext && ruby extconf.rb && make clean && make"
181
+ if RUBY_PLATFORM == "java"
182
+ system "cd ext && rake"
183
+ else
184
+ system "cd ext && ruby extconf.rb && make clean && make"
185
+ end
171
186
  end
172
187
 
173
188
  desc "Clean the AppSignal gem extension directory of installation artifacts"
@@ -1,7 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  require File.expand_path("../lib/appsignal/version", __FILE__)
3
4
 
4
- Gem::Specification.new do |gem|
5
+ Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
5
6
  gem.authors = [
6
7
  "Robert Beekman",
7
8
  "Thijs Cadier"
@@ -10,18 +11,24 @@ Gem::Specification.new do |gem|
10
11
  gem.description = "The official appsignal.com gem"
11
12
  gem.summary = "Logs performance and exception data from your app to "\
12
13
  "appsignal.com"
13
- gem.homepage = "https://github.com/appsignal/appsignal"
14
+ gem.homepage = "https://github.com/appsignal/appsignal-ruby"
14
15
  gem.license = "MIT"
15
16
 
16
17
  gem.files = `git ls-files`.split($\) # rubocop:disable Style/SpecialGlobalVars
17
18
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
18
19
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
20
  gem.name = "appsignal"
20
- gem.require_paths = %w(lib ext)
21
+ gem.require_paths = %w[lib ext]
21
22
  gem.version = Appsignal::VERSION
22
23
  gem.required_ruby_version = ">= 1.9"
23
24
 
24
- gem.extensions = %w(ext/extconf.rb)
25
+ if RUBY_PLATFORM == "java" || ENV["APPSIGNAL_PUSH_JAVA_GEM"]
26
+ gem.platform = "java"
27
+ gem.extensions = %w[ext/Rakefile]
28
+ gem.add_dependency "ffi"
29
+ else
30
+ gem.extensions = %w[ext/extconf.rb]
31
+ end
25
32
 
26
33
  gem.add_dependency "rack"
27
34
 
@@ -30,6 +37,6 @@ Gem::Specification.new do |gem|
30
37
  gem.add_development_dependency "pry"
31
38
  gem.add_development_dependency "timecop"
32
39
  gem.add_development_dependency "webmock"
33
- gem.add_development_dependency "rubocop", "0.46.0"
40
+ gem.add_development_dependency "rubocop", "0.49.0"
34
41
  gem.add_development_dependency "yard"
35
42
  end
@@ -0,0 +1,27 @@
1
+ require File.expand_path("../../lib/appsignal/version.rb", __FILE__)
2
+ require File.expand_path("../base.rb", __FILE__)
3
+
4
+ task :default do
5
+ begin
6
+ logger.info "Installing appsignal agent #{Appsignal::VERSION} for Ruby #{RUBY_VERSION} on #{RUBY_PLATFORM}"
7
+ write_agent_architecture
8
+ next unless check_architecture
9
+ arch_config = AGENT_CONFIG["triples"][ARCH]
10
+
11
+ unless File.exist?(ext_path("appsignal-agent")) &&
12
+ (
13
+ File.exist?(ext_path("libappsignal.dylib")) ||
14
+ File.exist?(ext_path("libappsignal.so"))
15
+ ) &&
16
+ File.exist?(ext_path("appsignal.h"))
17
+ archive = download_archive(arch_config, "dynamic")
18
+ next unless verify_archive(archive, arch_config, "dynamic")
19
+ unarchive(archive)
20
+ end
21
+ rescue => ex
22
+ installation_failed "Exception while installing: #{ex}"
23
+ ex.backtrace.each do |line|
24
+ logger.error line
25
+ end
26
+ end
27
+ end
@@ -1,33 +1,64 @@
1
1
  ---
2
- version: 98aef2c
2
+ version: 57a48f4
3
3
  triples:
4
4
  x86_64-darwin:
5
- checksum: 275b03a13348a853f188a1ca88c60478a802a6d75e78468234eb4842f26f666c
6
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-x86_64-darwin-all-static.tar.gz
5
+ static:
6
+ checksum: 4fa30287925bad17abb3e86784793e13399dd9390c0579ca94bd8f4ee7a832a3
7
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-darwin-all-static.tar.gz
8
+ dynamic:
9
+ checksum: 1380d4d7263b0fe2a546085efa64643289010b7dd21282c2900e81164a123e8d
10
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-darwin-all-dynamic.tar.gz
7
11
  universal-darwin:
8
- checksum: 275b03a13348a853f188a1ca88c60478a802a6d75e78468234eb4842f26f666c
9
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-x86_64-darwin-all-static.tar.gz
12
+ static:
13
+ checksum: 4fa30287925bad17abb3e86784793e13399dd9390c0579ca94bd8f4ee7a832a3
14
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-darwin-all-static.tar.gz
15
+ dynamic:
16
+ checksum: 1380d4d7263b0fe2a546085efa64643289010b7dd21282c2900e81164a123e8d
17
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-darwin-all-dynamic.tar.gz
10
18
  i686-linux:
11
- checksum: 7ae3942e3aa7cc659e2318f06cbe45b0dc9fbba219f804665b0bc60ea68efce4
12
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-i686-linux-all-static.tar.gz
19
+ static:
20
+ checksum: 9a1e59dd42e5ddcd0af04c0cffb0aadeace05dfae46d00aec71e90490186cbfd
21
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-i686-linux-all-static.tar.gz
22
+ dynamic:
23
+ checksum: ef45877189d3ea4be568ec2fa64a0f04fc94783c42e53f6a55672576a2cfb150
24
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-i686-linux-all-dynamic.tar.gz
13
25
  x86-linux:
14
- checksum: 7ae3942e3aa7cc659e2318f06cbe45b0dc9fbba219f804665b0bc60ea68efce4
15
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-i686-linux-all-static.tar.gz
26
+ static:
27
+ checksum: 9a1e59dd42e5ddcd0af04c0cffb0aadeace05dfae46d00aec71e90490186cbfd
28
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-i686-linux-all-static.tar.gz
29
+ dynamic:
30
+ checksum: ef45877189d3ea4be568ec2fa64a0f04fc94783c42e53f6a55672576a2cfb150
31
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-i686-linux-all-dynamic.tar.gz
16
32
  i686-linux-musl:
17
- checksum: 38859a7d5513f1aa3c849559807c4fba42c8fe76eb93eaf46a96fc5adb8c105a
18
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-i686-linux-musl-all-static.tar.gz
33
+ static:
34
+ checksum: cfa14d6aa3ad419a1d87854dfb13a780b34e4ccbf3afbe6adc7704ef750fc414
35
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-i686-linux-musl-all-static.tar.gz
19
36
  x86-linux-musl:
20
- checksum: 38859a7d5513f1aa3c849559807c4fba42c8fe76eb93eaf46a96fc5adb8c105a
21
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-i686-linux-musl-all-static.tar.gz
37
+ static:
38
+ checksum: cfa14d6aa3ad419a1d87854dfb13a780b34e4ccbf3afbe6adc7704ef750fc414
39
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-i686-linux-musl-all-static.tar.gz
22
40
  x86_64-linux:
23
- checksum: cbf6104586e004bbd6f0e67c8629224a27612ee24a5a9434a5240471330f73a4
24
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-x86_64-linux-all-static.tar.gz
41
+ static:
42
+ checksum: 8a68e7da4710fc97be73210437c890897a84f37f6ae9095f36d61099e52f07dc
43
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-linux-all-static.tar.gz
44
+ dynamic:
45
+ checksum: 5b2806ae841a6052f55c0824370dad41a04ae0ad2025df87a54847cce81054c3
46
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-linux-all-dynamic.tar.gz
25
47
  x86_64-linux-musl:
26
- checksum: 968964c84e0a640b2b7f50c376190d95aa5bee105361d0989c679bcc42f12f79
27
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-x86_64-linux-musl-all-static.tar.gz
48
+ static:
49
+ checksum: ffc91182064c1f0dbd9d219816054903fcc28db977cdd74df15802c468a2f252
50
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-linux-musl-all-static.tar.gz
28
51
  x86_64-freebsd:
29
- checksum: f9f604127a8315d776312a7ce608aa1df937ed0263a2f0d3ef871d6a0f470b8b
30
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-x86_64-freebsd-all-static.tar.gz
52
+ static:
53
+ checksum: c1781a09ec4e4c9e2f08a60e662acd8790286ebad62c9d32712a7932d0852a10
54
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-freebsd-all-static.tar.gz
55
+ dynamic:
56
+ checksum: 0ce479051f5734b330d91811c51813d93e65758ecad97e5f6b9e86764480e7c2
57
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-freebsd-all-dynamic.tar.gz
31
58
  amd64-freebsd:
32
- checksum: f9f604127a8315d776312a7ce608aa1df937ed0263a2f0d3ef871d6a0f470b8b
33
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/98aef2c/appsignal-x86_64-freebsd-all-static.tar.gz
59
+ static:
60
+ checksum: c1781a09ec4e4c9e2f08a60e662acd8790286ebad62c9d32712a7932d0852a10
61
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-freebsd-all-static.tar.gz
62
+ dynamic:
63
+ checksum: 0ce479051f5734b330d91811c51813d93e65758ecad97e5f6b9e86764480e7c2
64
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/57a48f4/appsignal-x86_64-freebsd-all-dynamic.tar.gz
@@ -0,0 +1,79 @@
1
+ require "digest"
2
+ require "logger"
3
+ require "fileutils"
4
+ require "open-uri"
5
+ require "zlib"
6
+ require "yaml"
7
+ require "rubygems/package"
8
+ require File.expand_path("../../lib/appsignal/system.rb", __FILE__)
9
+
10
+ EXT_PATH = File.expand_path("..", __FILE__).freeze
11
+ AGENT_CONFIG = YAML.load(File.read(File.join(EXT_PATH, "agent.yml"))).freeze
12
+
13
+ PLATFORM = Appsignal::System.agent_platform
14
+ ARCH = "#{RbConfig::CONFIG["host_cpu"]}-#{PLATFORM}".freeze
15
+ CA_CERT_PATH = File.join(EXT_PATH, "../resources/cacert.pem").freeze
16
+
17
+ def ext_path(path)
18
+ File.join(EXT_PATH, path)
19
+ end
20
+
21
+ def logger
22
+ @logger ||= Logger.new(File.join(EXT_PATH, "install.log"))
23
+ end
24
+
25
+ def installation_failed(reason)
26
+ logger.error "Installation failed: #{reason}"
27
+ File.open(File.join(EXT_PATH, "Makefile"), "w") do |file|
28
+ file.write "default:\nclean:\ninstall:"
29
+ end
30
+ end
31
+
32
+ def write_agent_architecture
33
+ File.open(File.join(EXT_PATH, "appsignal.architecture"), "w") do |file|
34
+ file.write ARCH
35
+ end
36
+ end
37
+
38
+ def check_architecture
39
+ if AGENT_CONFIG["triples"].keys.include?(ARCH)
40
+ true
41
+ else
42
+ installation_failed(
43
+ "AppSignal currently does not support your system architecture (#{ARCH})." \
44
+ "Please let us know at support@appsignal.com, we aim to support everything our customers run."
45
+ )
46
+ false
47
+ end
48
+ end
49
+
50
+ def download_archive(arch_config, type)
51
+ logger.info "Downloading agent release from #{arch_config[type]["download_url"]}"
52
+ open(arch_config[type]["download_url"], :ssl_ca_cert => CA_CERT_PATH)
53
+ end
54
+
55
+ def verify_archive(archive, arch_config, type)
56
+ if Digest::SHA256.hexdigest(archive.read) == arch_config[type]["checksum"]
57
+ logger.info "Checksum of downloaded archive verified, extracting archive"
58
+ true
59
+ else
60
+ installation_failed(
61
+ "Aborting installation, checksum of downloaded archive could not be verified: " \
62
+ "Expected '#{arch_config[type]["checksum"]}', got '#{checksum}'."
63
+ )
64
+ false
65
+ end
66
+ end
67
+
68
+ def unarchive(archive)
69
+ Gem::Package::TarReader.new(Zlib::GzipReader.open(archive)) do |tar|
70
+ tar.each do |entry|
71
+ next unless entry.file?
72
+
73
+ File.open(ext_path(entry.full_name), "wb") do |f|
74
+ f.write(entry.read)
75
+ end
76
+ end
77
+ end
78
+ FileUtils.chmod(0o755, ext_path("appsignal-agent"))
79
+ end
@@ -1,89 +1,18 @@
1
- require "digest"
2
- require "logger"
3
- require "fileutils"
4
- require "open-uri"
5
- require "zlib"
6
- require "rubygems/package"
7
- require "yaml"
8
1
  require File.expand_path("../../lib/appsignal/version.rb", __FILE__)
9
- require File.expand_path("../../lib/appsignal/system.rb", __FILE__)
10
-
11
- EXT_PATH = File.expand_path("..", __FILE__).freeze
12
- AGENT_CONFIG = YAML.load(File.read(File.join(EXT_PATH, "agent.yml"))).freeze
13
-
14
- PLATFORM = Appsignal::System.agent_platform
15
- ARCH = "#{Gem::Platform.local.cpu}-#{PLATFORM}".freeze
16
- CA_CERT_PATH = File.join(EXT_PATH, "../resources/cacert.pem").freeze
17
-
18
- def ext_path(path)
19
- File.join(EXT_PATH, path)
20
- end
21
-
22
- def logger
23
- @logger ||= Logger.new(File.join(EXT_PATH, "install.log"))
24
- end
25
-
26
- def installation_failed(reason)
27
- logger.error "Installation failed: #{reason}"
28
- File.open(File.join(EXT_PATH, "Makefile"), "w") do |file|
29
- file.write "default:\nclean:\ninstall:"
30
- end
31
- end
32
-
33
- def write_agent_architecture
34
- File.open(File.join(EXT_PATH, "appsignal.architecture"), "w") do |file|
35
- file.write ARCH
36
- end
37
- end
2
+ require File.expand_path("../base.rb", __FILE__)
38
3
 
39
4
  def install
40
5
  logger.info "Installing appsignal agent #{Appsignal::VERSION} for Ruby #{RUBY_VERSION} on #{RUBY_PLATFORM}"
41
6
  write_agent_architecture
42
-
43
- if RUBY_PLATFORM =~ /java/
44
- installation_failed(
45
- "We do not support jRuby at the moment, email support@appsignal.com if you want to join the beta"
46
- )
47
- return
48
- end
49
-
50
- unless AGENT_CONFIG["triples"].keys.include?(ARCH)
51
- installation_failed(
52
- "AppSignal currently does not support your system architecture (#{ARCH})." \
53
- "Please let us know at support@appsignal.com, we aim to support everything our customers run."
54
- )
55
- return
56
- end
57
-
7
+ return unless check_architecture
58
8
  arch_config = AGENT_CONFIG["triples"][ARCH]
59
9
 
60
10
  unless File.exist?(ext_path("appsignal-agent")) &&
61
11
  File.exist?(ext_path("libappsignal.a")) &&
62
12
  File.exist?(ext_path("appsignal.h"))
63
- logger.info "Downloading agent release from #{arch_config["download_url"]}"
64
-
65
- archive = open(arch_config["download_url"], :ssl_ca_cert => CA_CERT_PATH)
66
-
67
- if Digest::SHA256.hexdigest(archive.read) == arch_config["checksum"]
68
- logger.info "Checksum of downloaded archive verified, extracting archive"
69
- else
70
- installation_failed(
71
- "Aborting installation, checksum of downloaded archive could not be verified: " \
72
- "Expected '#{arch_config["checksum"]}', got '#{checksum}'."
73
- )
74
- return
75
- end
76
-
77
- Gem::Package::TarReader.new(Zlib::GzipReader.open(archive)) do |tar|
78
- tar.each do |entry|
79
- next unless entry.file?
80
-
81
- File.open(ext_path(entry.full_name), "wb") do |f|
82
- f.write(entry.read)
83
- end
84
- end
85
- end
86
- FileUtils.chmod(0o755, ext_path("appsignal-agent"))
13
+ archive = download_archive(arch_config, "static")
14
+ return unless verify_archive(archive, arch_config, "static")
15
+ unarchive(archive)
87
16
  end
88
17
 
89
18
  logger.info "Creating makefile"