puma-redeploy 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65da7c1d7658a5e9bc5e955e5c3392dce1c9300ae20cfec2220e60f15804fb0b
4
- data.tar.gz: 984a126a32edbf6289aeda36855d801923ab54f4b959b561eb8b41d1e08bba93
3
+ metadata.gz: 95576842e0df654976d5f2ec42a799b6f069216f5904c1365aa77207bd8c9ba3
4
+ data.tar.gz: 0211c3134cad5f3cdfc0982c5378cfbc5270d16360d030f2cee8b739c412e940
5
5
  SHA512:
6
- metadata.gz: 6988a62ccf3b83669e8f4e4e361bc48b062f1df6c7cc704903034dac9385f29c6648faaf04393ac88f9a78fa83301ec6820c74043237baa52d99536987a3ba4f
7
- data.tar.gz: c962806cc92fe13e2b14aae40cd0d9413b14fb249c3eb72f106686b143217e08e40fb2e49068ea15a1be7893a5248ca79e0c6ef3c86bff5c29ddf026414b2be6
6
+ metadata.gz: ff3c3600e965c7101b2a28803297a446d4be1fddc63d852341dde3114cf24a4d5ef9bac25556b2a3b4e1a3f51a8af54f25f04167d1ef9b49144e26e087acf893
7
+ data.tar.gz: cf2d71b61daec38e7ad35a32a6c737ea995b9572637a378faa661fa6c895add5df2a9be5d99e8a518ff6f4b91ecb3263958680919313293023488177a22993e9
data/CHANGELOG.md CHANGED
@@ -1,9 +1,17 @@
1
-
2
1
  # Changelog
3
2
 
4
- ## v0.2.x (NEXT)
3
+ ## v0.3.1
5
4
 
6
- **Features:**
5
+ **Fixes and enhancements:**
6
+
7
+ - Allow watch file to not exist
8
+
9
+
10
+ ## v0.3.0
11
+
12
+ **Breaking Changes:**
13
+ - Rename load_archive to archive-loader
14
+ - Add options flags to archive-loader
7
15
 
8
16
  **Fixes and enhancements:**
9
17
 
data/Gemfile CHANGED
@@ -4,3 +4,12 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in puma-redeploy.gemspec
6
6
  gemspec
7
+
8
+ gem 'rake', '~> 13.0.6'
9
+ gem 'rspec', '~> 3.12.0'
10
+ gem 'rubocop', '~> 1.43'
11
+ gem 'rubocop-performance', '~> 1.15'
12
+ gem 'rubocop-rake', '~> 0.6.0'
13
+ gem 'rubocop-rspec', '~> 2.17'
14
+ gem 'rubocop-thread_safety', '~> 0.4.4'
15
+ gem 'timecop', '~> 0.9.6'
data/README.md CHANGED
@@ -4,16 +4,19 @@ The puma-redeploy gem is a puma plugin that allows you to redeploy a new version
4
4
 
5
5
  Key Points:
6
6
  * Encourages the separation of the build process from deployment
7
+ * Runtime container does not include application code
7
8
  * Leverages Puma [phased-restart](https://github.com/puma/puma/blob/master/docs/restart.md#phased-restart) to ensure uptime deploy
8
9
  * Deploys in seconds
9
- * Plugable handlers to detect redeploy (File, S3, Artifactory, etc..)
10
+ * Pluggable handlers to detect redeploy (File, S3, Artifactory, etc..)
10
11
 
12
+ **Note** - Currently there are File and S3 handlers for loading archives.
11
13
 
12
14
  ![image](https://user-images.githubusercontent.com/121275/219976698-80575b17-17b7-4861-8c10-675f3f615e25.png)
13
15
 
14
16
 
15
17
  Example application can be found [here](https://github.com/tbeauvais/puma-redeploy-test-app)
16
18
 
19
+ Also see the [sidekiq-redeploy](https://github.com/tbeauvais/sidekiq-redeploy) gem.
17
20
 
18
21
  ## Installation
19
22
 
@@ -39,10 +42,9 @@ Update your `config/puma.rb` config file with the following
39
42
  # Add the puma-redeploy plugin
40
43
  plugin :redeploy
41
44
 
42
- # specify the redeploy watch file
43
- redeploy_watch_file './watch_me'
44
- # For S3 this must be a S3 URL
45
- redeploy_watch_file 's3://puma-test-app-archives/watch.me'
45
+ # Specify the redeploy watch file from an environment variable. This can a file system location or S3 URL. For example `/app/pkg/watch.me` or `s3://puma-test-app-archives/watch.me`.
46
+ redeploy_watch_file ENV['WATCH_FILE']
47
+
46
48
 
47
49
  # Specify the number of seconds between checking watch file. Defaults to 30.
48
50
  redeploy_watch_delay 15
@@ -50,14 +52,31 @@ redeploy_watch_delay 15
50
52
  ```
51
53
 
52
54
  The watch file must contain the path to the current archive. This can be a file path or S3 URL.
55
+
53
56
  For example when using a file:
54
57
  ```
55
- /sinatra_test/pkg/test_app_0.0.1.zip
58
+ /app/pkg/test_app_0.0.3.zip
56
59
  ```
57
60
 
58
61
  For example when using S3:
59
62
  ```
60
- s3://puma-test-app-archives/test_app_0.0.1.zip
63
+ s3://puma-test-app-archives/test_app_0.0.3.zip
64
+ ```
65
+
66
+ ### Archive Loader
67
+ The `archive-loader` is a cli used to fetch and deploy the application archive prior to starting the puma server. This is useful when the application code does not exist in the runtime container.
68
+
69
+ ```shell
70
+ archive-loader
71
+ Usage: archive-loader [options]. Used to load the archive prior to starting the puma app server.
72
+ -a, --app-dir=DIR [Required] Location of application directory within the container.
73
+ -w, --watch=WATCH [Required] Location of watch file (file or s3 location).
74
+ -h, --help Prints this help
75
+ ```
76
+
77
+ For example this will fetch and unzip the application archive and then start puma.
78
+ ```shell
79
+ archive-loader -a /app -w /app/pkg/watch.me && bundle exec puma -C config/puma.rb
61
80
  ```
62
81
 
63
82
  ## Development
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'puma-redeploy'
6
+ require 'logger'
7
+ require 'optparse'
8
+
9
+ def deploy_archive(app_dir, watch_file, logger)
10
+ handler = Puma::Redeploy::DeployerFactory.create(target: app_dir, watch_file:,
11
+ logger:)
12
+ handler.deploy(source: handler.archive_file)
13
+ end
14
+
15
+ def option_parser(opts)
16
+ OptionParser.new do |o|
17
+ o.banner = 'Usage: archive-loader [options]. Used to load the archive prior to starting the puma app server.'
18
+
19
+ o.on '-a', '--app-dir=DIR', '[Required] Location of application directory within the container.' do |arg|
20
+ opts[:app_dir] = arg
21
+ end
22
+
23
+ o.on '-w', '--watch=WATCH', '[Required] Location of watch file (file or s3 location).' do |arg|
24
+ opts[:watch] = arg
25
+ end
26
+
27
+ o.on('-h', '--help', 'Prints this help') do
28
+ puts o
29
+ exit
30
+ end
31
+ end
32
+ end
33
+
34
+ def logger
35
+ Logger.new($stdout)
36
+ end
37
+
38
+ ops = {}
39
+ parser = option_parser(ops)
40
+ parser.parse!(ARGV)
41
+
42
+ unless ops[:app_dir] && ops[:watch]
43
+ puts parser.help
44
+ exit 1
45
+ end
46
+
47
+ deploy_archive(ops[:app_dir], ops[:watch], logger)
@@ -55,6 +55,9 @@ module Puma
55
55
  logger.info "The S3 object #{bucket_name}/#{object_key} does not exist"
56
56
  0
57
57
  end
58
+ rescue StandardError => e
59
+ logger.warn "Error accessing the S3 object #{bucket_name}/#{object_key}. Error:#{e.message}"
60
+ 0
58
61
  end
59
62
  end
60
63
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Puma
4
4
  module Redeploy
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.license = 'MIT'
17
17
  spec.required_ruby_version = Gem::Requirement.new('>= 3.1.0')
18
18
 
19
- spec.executables = ['load_archive']
19
+ spec.executables = ['archive-loader']
20
20
 
21
21
  spec.metadata['homepage_uri'] = spec.homepage
22
22
  spec.metadata['source_code_uri'] = 'https://github.com/tbeauvais/puma-redeploy'
@@ -32,13 +32,5 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_runtime_dependency 'aws-sdk-s3', '~> 1.120.0'
34
34
 
35
- spec.add_development_dependency 'rake', '~> 13.0.6'
36
- spec.add_development_dependency 'rspec', '~> 3.12.0'
37
- spec.add_development_dependency 'rubocop', '~> 1.43'
38
- spec.add_development_dependency 'rubocop-performance', '~> 1.15'
39
- spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
40
- spec.add_development_dependency 'rubocop-rspec', '~> 2.17'
41
- spec.add_development_dependency 'rubocop-thread_safety', '~> 0.4.4'
42
- spec.add_development_dependency 'timecop', '~> 0.9.6'
43
35
  spec.metadata['rubygems_mfa_required'] = 'true'
44
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-redeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tbeauvais
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-21 00:00:00.000000000 Z
11
+ date: 2023-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -24,125 +24,13 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.120.0
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 13.0.6
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 13.0.6
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 3.12.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 3.12.0
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.43'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.43'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.15'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.15'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.6.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.6.0
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '2.17'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '2.17'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-thread_safety
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.4.4
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.4.4
125
- - !ruby/object:Gem::Dependency
126
- name: timecop
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 0.9.6
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 0.9.6
139
27
  description: Puma plugin to redeploy and reload app from a remote artifact. This will
140
28
  detect app changes, once detected a new artifact will be pulled and the app will
141
29
  be reloaded.
142
30
  email:
143
31
  - tbeauvais1@gmail.com
144
32
  executables:
145
- - load_archive
33
+ - archive-loader
146
34
  extensions: []
147
35
  extra_rdoc_files: []
148
36
  files:
@@ -158,7 +46,7 @@ files:
158
46
  - LICENSE.txt
159
47
  - README.md
160
48
  - Rakefile
161
- - bin/load_archive
49
+ - bin/archive-loader
162
50
  - lib/puma-redeploy.rb
163
51
  - lib/puma/plugin/redeploy.rb
164
52
  - lib/puma/redeploy/base_handler.rb
data/bin/load_archive DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # frozen_string_literal: true
4
-
5
- require 'puma-redeploy'
6
- require 'logger'
7
-
8
- def deploy_archive(app_dir, watch_file, logger)
9
- handler = Puma::Redeploy::DeployerFactory.create(target: app_dir, watch_file:,
10
- logger:)
11
- handler.deploy(source: handler.archive_file)
12
- end
13
-
14
- logger = Logger.new($stdout)
15
-
16
- if ARGV.size != 2
17
- logger.error 'You must specify the application directory and watch file'
18
- logger.info 'load_archive <app directory> <watch file>'
19
- logger.info 'e.g. load_archive /app /build/pkg/watch.me'
20
- exit(1)
21
- end
22
-
23
- app_dir = ARGV[0]
24
- watch_file = ARGV[1]
25
-
26
- deploy_archive(app_dir, watch_file, logger)