puma-redeploy 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -3
- data/README.md +25 -7
- data/bin/archive-loader +47 -0
- data/lib/puma/redeploy/version.rb +1 -1
- data/puma-redeploy.gemspec +1 -1
- metadata +4 -4
- data/bin/load_archive +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed0d1a89c2ce26afe253893f3a716e346edb7b7bfe109c0acf6c1cc2599db23
|
4
|
+
data.tar.gz: 39a7a76965ca098d9dcfb0586d5d96f3c47326fafd4aa22b3a6a9f68d7358e4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfd1f53e8d88ea177310c7797428f924ac4b865dcce699a6f299be86510a6d1b702b86fbc934cba9c727f3df6a2834194c6ecfde4b113b7a0ebf845b264989fc
|
7
|
+
data.tar.gz: c9bd80080b88819fbd3a03ec49cd8649fa80dbc6b10d15d2a2f063b97ed74aabb276aac02df48a6a1744033af0240be17ca95ef6b85a88626ff65f306e638575
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,10 +4,12 @@ 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
|
-
*
|
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
|
|
@@ -39,10 +41,9 @@ Update your `config/puma.rb` config file with the following
|
|
39
41
|
# Add the puma-redeploy plugin
|
40
42
|
plugin :redeploy
|
41
43
|
|
42
|
-
#
|
43
|
-
redeploy_watch_file '
|
44
|
-
|
45
|
-
redeploy_watch_file 's3://puma-test-app-archives/watch.me'
|
44
|
+
# 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`.
|
45
|
+
redeploy_watch_file ENV['WATCH_FILE']
|
46
|
+
|
46
47
|
|
47
48
|
# Specify the number of seconds between checking watch file. Defaults to 30.
|
48
49
|
redeploy_watch_delay 15
|
@@ -50,14 +51,31 @@ redeploy_watch_delay 15
|
|
50
51
|
```
|
51
52
|
|
52
53
|
The watch file must contain the path to the current archive. This can be a file path or S3 URL.
|
54
|
+
|
53
55
|
For example when using a file:
|
54
56
|
```
|
55
|
-
/
|
57
|
+
/app/pkg/test_app_0.0.3.zip
|
56
58
|
```
|
57
59
|
|
58
60
|
For example when using S3:
|
59
61
|
```
|
60
|
-
s3://puma-test-app-archives/test_app_0.0.
|
62
|
+
s3://puma-test-app-archives/test_app_0.0.3.zip
|
63
|
+
```
|
64
|
+
|
65
|
+
### Archive Loader
|
66
|
+
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.
|
67
|
+
|
68
|
+
```shell
|
69
|
+
archive-loader
|
70
|
+
Usage: archive-loader [options]. Used to load the archive prior to starting the puma app server.
|
71
|
+
-a, --app-dir=DIR [Required] Location of application directory within the container.
|
72
|
+
-w, --watch=WATCH [Required] Location of watch file (file or s3 location).
|
73
|
+
-h, --help Prints this help
|
74
|
+
```
|
75
|
+
|
76
|
+
For example this will fetch and unzip the application archive and then start puma.
|
77
|
+
```shell
|
78
|
+
archive-loader /app /app/pkg/watch.me && bundle exec puma -C config/puma.rb
|
61
79
|
```
|
62
80
|
|
63
81
|
## Development
|
data/bin/archive-loader
ADDED
@@ -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)
|
data/puma-redeploy.gemspec
CHANGED
@@ -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 = ['
|
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'
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbeauvais
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
@@ -142,7 +142,7 @@ description: Puma plugin to redeploy and reload app from a remote artifact. This
|
|
142
142
|
email:
|
143
143
|
- tbeauvais1@gmail.com
|
144
144
|
executables:
|
145
|
-
-
|
145
|
+
- archive-loader
|
146
146
|
extensions: []
|
147
147
|
extra_rdoc_files: []
|
148
148
|
files:
|
@@ -158,7 +158,7 @@ files:
|
|
158
158
|
- LICENSE.txt
|
159
159
|
- README.md
|
160
160
|
- Rakefile
|
161
|
-
- bin/
|
161
|
+
- bin/archive-loader
|
162
162
|
- lib/puma-redeploy.rb
|
163
163
|
- lib/puma/plugin/redeploy.rb
|
164
164
|
- 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)
|