puma-redeploy 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/pull_request_template.md +9 -0
- data/.github/workflows/pr.yml +26 -0
- data/.github/workflows/publish_gem.yml +16 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.rubocop.yml +22 -0
- data/CHANGELOG.md +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +80 -0
- data/Rakefile +16 -0
- data/bin/load_archive +30 -0
- data/lib/puma/plugin/redeploy.rb +36 -0
- data/lib/puma/redeploy/deployer_factory.rb +13 -0
- data/lib/puma/redeploy/dsl.rb +22 -0
- data/lib/puma/redeploy/file_deployer.rb +24 -0
- data/lib/puma/redeploy/file_handler.rb +45 -0
- data/lib/puma/redeploy/version.rb +7 -0
- data/lib/puma-redeploy.rb +3 -0
- data/lib/puma_redeploy.rb +10 -0
- data/puma-redeploy.gemspec +42 -0
- metadata +184 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 71217e13019896c5b071db53e1b149ddb34d5dd5cf98eb5cd2da7f189c335f6a
|
|
4
|
+
data.tar.gz: 32b87f0dd6e54ca89bc0be6032d60c37fb6e88f6fd58eae15e25cb4bc13aebad
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bcf4d8732453d835c898595bff21c84a31d8b1f5b30f5cf9a46f1f6c33d3e5dfdf4fcbcc9416a698caa70acb17b4fa319144e3a8e0f3f85af944e5d914ba1ab8
|
|
7
|
+
data.tar.gz: e7bbea1217f1eaa8f1bab4d3d0d4d9a798f477d42a28fe79b682251b8e3dd0f5525e4a63aea3dfec880e20c182060dbc81e4b72c05eea53e539f29bcc84ad6d7
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
### Description
|
|
2
|
+
> Please describe your pull request. Thank you for contributing!
|
|
3
|
+
|
|
4
|
+
### Your checklist for this pull request
|
|
5
|
+
- [ ] I have added (or updated) appropriate tests if this PR fixes a bug or adds a feature.
|
|
6
|
+
- [ ] My pull request is 100 lines added/removed or less so that it can be easily reviewed.
|
|
7
|
+
- [ ] If this closes any issues, I have added "Closes `#issue`" to the PR description or my commit messages.
|
|
8
|
+
- [ ] I have updated the documentation accordingly.
|
|
9
|
+
- [ ] All new and existing tests passed, including Rubocop.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Pull Request
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
ruby-version: ['3.2.2', '3.1.3']
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
18
|
+
uses: ruby/setup-ruby@v1
|
|
19
|
+
with:
|
|
20
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: bundle install
|
|
23
|
+
- name: Run rubocop
|
|
24
|
+
run: bundle exec rubocop
|
|
25
|
+
- name: Run tests
|
|
26
|
+
run: bundle exec rake spec
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Build and publish gem to github package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
build:
|
|
8
|
+
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- name: Build and publish gem
|
|
14
|
+
uses: dawidd6/action-publish-gem@v1
|
|
15
|
+
with:
|
|
16
|
+
api_key: ${{secrets.RUBYGEMS_API_KEY}}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.7
|
|
3
|
+
DisplayCopNames: true
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
NewCops: enable
|
|
6
|
+
Exclude:
|
|
7
|
+
- 'lib/puma-redeploy.rb'
|
|
8
|
+
|
|
9
|
+
require:
|
|
10
|
+
- rubocop-rake
|
|
11
|
+
- rubocop-performance
|
|
12
|
+
- rubocop-rspec
|
|
13
|
+
- rubocop-thread_safety
|
|
14
|
+
|
|
15
|
+
Metrics/BlockLength:
|
|
16
|
+
AllowedMethods: ['describe', 'context']
|
|
17
|
+
|
|
18
|
+
Metrics/MethodLength:
|
|
19
|
+
Max: 30
|
|
20
|
+
|
|
21
|
+
RSpec/NestedGroups:
|
|
22
|
+
Max: 4
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at tbeauvais1@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: https://contributor-covenant.org
|
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 tbeauvais
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Puma Redeploy
|
|
2
|
+
|
|
3
|
+
The puma-redeploy gem is a puma plugin that allows you to redeploy a new version of your Ruby application in a container without a full container deploy.
|
|
4
|
+
|
|
5
|
+
Key Points:
|
|
6
|
+
* Encourages the separation of the build process from deployment
|
|
7
|
+
* Leverages Puma [phased-restart](https://github.com/puma/puma/blob/master/docs/restart.md#phased-restart) to ensure uptime deploy
|
|
8
|
+
* Deploys in seconds
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Example application can be found [here](https://github.com/tbeauvais/sinatra-api-base)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Add this line to your application's Gemfile:
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
gem 'puma-redeploy'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
And then execute:
|
|
26
|
+
|
|
27
|
+
$ bundle install
|
|
28
|
+
|
|
29
|
+
Or install it yourself as:
|
|
30
|
+
|
|
31
|
+
$ gem install puma-redeploy
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Update your `config/puma.rb` config file with the following
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Add the puma-redeploy plugin
|
|
39
|
+
plugin :redeploy
|
|
40
|
+
|
|
41
|
+
# specify the redeploy watch file
|
|
42
|
+
redeploy_watch_file './watch_me'
|
|
43
|
+
|
|
44
|
+
# Specify the number of seconds between checking watch file. Defaults to 30.
|
|
45
|
+
redeploy_watch_delay 15
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The watch file must contain the path to the current archive.
|
|
50
|
+
For example:
|
|
51
|
+
```
|
|
52
|
+
/sinatra_test/pkg/my_application_0.0.1.zip
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Development
|
|
56
|
+
|
|
57
|
+
After checking out the repo, run `bundle` to install dependencies. Then, run `rake spec` to run the tests and `rake rubocop` to check for rubocop offences.
|
|
58
|
+
|
|
59
|
+
To install this gem onto your local machine, run the following. **Note** - You must add any new files to git first.
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
bundle exec rake install
|
|
63
|
+
puma-redeploy 0.1.0 built to pkg/puma-redeploy-0.1.0.gem.
|
|
64
|
+
puma-redeploy (0.1.0) installed.
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
68
|
+
|
|
69
|
+
## Contributing
|
|
70
|
+
|
|
71
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/puma-redeploy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/puma-redeploy/blob/master/CODE_OF_CONDUCT.md).
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
77
|
+
|
|
78
|
+
## Code of Conduct
|
|
79
|
+
|
|
80
|
+
Everyone interacting in the Puma::Redeploy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/puma-redeploy/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
|
|
6
|
+
begin
|
|
7
|
+
# Add rubocop task
|
|
8
|
+
require 'rubocop/rake_task'
|
|
9
|
+
RuboCop::RakeTask.new
|
|
10
|
+
rescue LoadError
|
|
11
|
+
# Ignore
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
15
|
+
|
|
16
|
+
task default: :spec
|
data/bin/load_archive
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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: watch_file,
|
|
10
|
+
logger: 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
|
+
end
|
|
21
|
+
|
|
22
|
+
app_dir = ARGV[0]
|
|
23
|
+
watch_file = ARGV[1]
|
|
24
|
+
|
|
25
|
+
if File.exist?(watch_file) && Dir.exist?(app_dir)
|
|
26
|
+
deploy_archive(app_dir, watch_file, logger)
|
|
27
|
+
else
|
|
28
|
+
logger.error "watch_file #{watch_file} does not exist" unless File.exist?(watch_file)
|
|
29
|
+
logger.error "app_dir #{app_dir} does not exist" unless Dir.exist?(app_dir)
|
|
30
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'puma-redeploy'
|
|
4
|
+
# require 'puma/plugin'
|
|
5
|
+
# require 'puma/redeploy/dsl'
|
|
6
|
+
# require 'puma/redeploy/file_handler'
|
|
7
|
+
# require 'puma/redeploy/file_deployer'
|
|
8
|
+
# require 'puma/redeploy/deployer_factory'
|
|
9
|
+
require 'logger'
|
|
10
|
+
|
|
11
|
+
Puma::Plugin.create do
|
|
12
|
+
def start(launcher)
|
|
13
|
+
in_background do
|
|
14
|
+
logger = launcher.options[:redeploy_logger] || Logger.new($stdout)
|
|
15
|
+
watch_file = launcher.options[:redeploy_watch_file]
|
|
16
|
+
handler = Puma::Redeploy::DeployerFactory.create(target: launcher.restart_dir, watch_file: watch_file,
|
|
17
|
+
logger: logger)
|
|
18
|
+
|
|
19
|
+
delay = launcher.options[:redeploy_watch_delay] || 30
|
|
20
|
+
monitor_loop(handler, delay, launcher, logger)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
def monitor_loop(handler, delay, launcher, logger)
|
|
25
|
+
loop do
|
|
26
|
+
sleep delay
|
|
27
|
+
|
|
28
|
+
next unless handler.needs_redeploy?
|
|
29
|
+
|
|
30
|
+
logger.info "Puma phased_restart begin file=#{handler.watch_file} archive=#{handler.archive_file}"
|
|
31
|
+
|
|
32
|
+
handler.deploy(source: handler.archive_file)
|
|
33
|
+
|
|
34
|
+
launcher.phased_restart
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Puma
|
|
4
|
+
module Redeploy
|
|
5
|
+
# Creates instance if deployer implementation
|
|
6
|
+
class DeployerFactory
|
|
7
|
+
def self.create(target:, watch_file:, logger:)
|
|
8
|
+
file_deployer = Puma::Redeploy::FileDeployer.new(target: target, logger: logger)
|
|
9
|
+
Puma::Redeploy::FileHandler.new(watch_file: watch_file, deployer: file_deployer, logger: logger)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Puma
|
|
4
|
+
# Allowed options for puma redeploy
|
|
5
|
+
class DSL
|
|
6
|
+
def redeploy_watch_file(file_name)
|
|
7
|
+
@options[:redeploy_watch_file] = file_name
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def redeploy_watch_delay(delay_time)
|
|
11
|
+
@options[:redeploy_watch_delay] = delay_time
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def redeploy_debug(enable: true)
|
|
15
|
+
@options[:redeploy_debug] = enable
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def redeploy_logger(logger)
|
|
19
|
+
@options[:redeploy_logger] = logger
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
|
|
5
|
+
module Puma
|
|
6
|
+
module Redeploy
|
|
7
|
+
# Deploys zip archive
|
|
8
|
+
class FileDeployer
|
|
9
|
+
def initialize(target:, logger:)
|
|
10
|
+
@target = target
|
|
11
|
+
@logger = logger
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def deploy(source:)
|
|
15
|
+
Dir.chdir(@target) do
|
|
16
|
+
stdout, stderr, status = Open3.capture3("unzip -o -K #{source}")
|
|
17
|
+
@logger.info "stdout: #{stdout}"
|
|
18
|
+
@logger.info "stderr: #{stderr}"
|
|
19
|
+
@logger.info "status: #{status.exitstatus}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'forwardable'
|
|
4
|
+
|
|
5
|
+
module Puma
|
|
6
|
+
module Redeploy
|
|
7
|
+
# file based redeploy handler
|
|
8
|
+
class FileHandler
|
|
9
|
+
extend Forwardable
|
|
10
|
+
attr_reader :watch_file
|
|
11
|
+
|
|
12
|
+
def initialize(watch_file:, deployer:, logger:)
|
|
13
|
+
@watch_file = watch_file
|
|
14
|
+
@logger = logger
|
|
15
|
+
@touched_at = touched_at
|
|
16
|
+
@deployer = deployer
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def_delegators :@deployer, :deploy
|
|
20
|
+
def needs_redeploy?
|
|
21
|
+
return false unless (mtime = touched_at) != @touched_at
|
|
22
|
+
|
|
23
|
+
@touched_at = mtime
|
|
24
|
+
true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def archive_file
|
|
28
|
+
File.read(watch_file)&.strip
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
attr_accessor :logger
|
|
34
|
+
|
|
35
|
+
def touched_at
|
|
36
|
+
if File.exist?(watch_file)
|
|
37
|
+
File.mtime(watch_file)
|
|
38
|
+
else
|
|
39
|
+
logger.info "Watch file (#{watch_file}) does not exist"
|
|
40
|
+
0
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/puma/redeploy/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'puma-redeploy'
|
|
7
|
+
spec.version = Puma::Redeploy::VERSION
|
|
8
|
+
spec.authors = ['tbeauvais']
|
|
9
|
+
spec.email = ['tbeauvais1@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Puma plugin to redeploy and reload app from artifact.'
|
|
12
|
+
spec.description = 'Puma plugin to redeploy and reload app from a remote artifact. ' \
|
|
13
|
+
'This will detect app changes, once detected a new artifact ' \
|
|
14
|
+
'will be pulled and the app will be reloaded.'
|
|
15
|
+
spec.homepage = 'https://github.com/tbeauvais/puma-redeploy'
|
|
16
|
+
spec.license = 'MIT'
|
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
|
18
|
+
|
|
19
|
+
spec.executables = ['load_archive']
|
|
20
|
+
|
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
22
|
+
spec.metadata['source_code_uri'] = 'https://github.com/tbeauvais/puma-redeploy'
|
|
23
|
+
spec.metadata['changelog_uri'] = 'https://github.com/tbeauvais/puma-redeploy/CHANGELOG.md'
|
|
24
|
+
|
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
27
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
29
|
+
end
|
|
30
|
+
spec.bindir = 'bin'
|
|
31
|
+
spec.require_paths = ['lib']
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency 'rake', '~> 13.0.6'
|
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.12.0'
|
|
35
|
+
spec.add_development_dependency 'rubocop', '~> 1.43'
|
|
36
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.15'
|
|
37
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
|
38
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.17'
|
|
39
|
+
spec.add_development_dependency 'rubocop-thread_safety', '~> 0.4.4'
|
|
40
|
+
spec.add_development_dependency 'timecop', '~> 0.9.6'
|
|
41
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
42
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: puma-redeploy
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- tbeauvais
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-04-14 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 13.0.6
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 13.0.6
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 3.12.0
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 3.12.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rubocop
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.43'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.43'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop-performance
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.15'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.15'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rubocop-rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.6.0
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.6.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop-rspec
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2.17'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2.17'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rubocop-thread_safety
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 0.4.4
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 0.4.4
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: timecop
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.9.6
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.9.6
|
|
125
|
+
description: Puma plugin to redeploy and reload app from a remote artifact. This will
|
|
126
|
+
detect app changes, once detected a new artifact will be pulled and the app will
|
|
127
|
+
be reloaded.
|
|
128
|
+
email:
|
|
129
|
+
- tbeauvais1@gmail.com
|
|
130
|
+
executables:
|
|
131
|
+
- load_archive
|
|
132
|
+
extensions: []
|
|
133
|
+
extra_rdoc_files: []
|
|
134
|
+
files:
|
|
135
|
+
- ".github/pull_request_template.md"
|
|
136
|
+
- ".github/workflows/pr.yml"
|
|
137
|
+
- ".github/workflows/publish_gem.yml"
|
|
138
|
+
- ".gitignore"
|
|
139
|
+
- ".rspec"
|
|
140
|
+
- ".rubocop.yml"
|
|
141
|
+
- CHANGELOG.md
|
|
142
|
+
- CODE_OF_CONDUCT.md
|
|
143
|
+
- Gemfile
|
|
144
|
+
- LICENSE.txt
|
|
145
|
+
- README.md
|
|
146
|
+
- Rakefile
|
|
147
|
+
- bin/load_archive
|
|
148
|
+
- lib/puma-redeploy.rb
|
|
149
|
+
- lib/puma/plugin/redeploy.rb
|
|
150
|
+
- lib/puma/redeploy/deployer_factory.rb
|
|
151
|
+
- lib/puma/redeploy/dsl.rb
|
|
152
|
+
- lib/puma/redeploy/file_deployer.rb
|
|
153
|
+
- lib/puma/redeploy/file_handler.rb
|
|
154
|
+
- lib/puma/redeploy/version.rb
|
|
155
|
+
- lib/puma_redeploy.rb
|
|
156
|
+
- puma-redeploy.gemspec
|
|
157
|
+
homepage: https://github.com/tbeauvais/puma-redeploy
|
|
158
|
+
licenses:
|
|
159
|
+
- MIT
|
|
160
|
+
metadata:
|
|
161
|
+
homepage_uri: https://github.com/tbeauvais/puma-redeploy
|
|
162
|
+
source_code_uri: https://github.com/tbeauvais/puma-redeploy
|
|
163
|
+
changelog_uri: https://github.com/tbeauvais/puma-redeploy/CHANGELOG.md
|
|
164
|
+
rubygems_mfa_required: 'true'
|
|
165
|
+
post_install_message:
|
|
166
|
+
rdoc_options: []
|
|
167
|
+
require_paths:
|
|
168
|
+
- lib
|
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: 2.7.0
|
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
|
+
requirements:
|
|
176
|
+
- - ">="
|
|
177
|
+
- !ruby/object:Gem::Version
|
|
178
|
+
version: '0'
|
|
179
|
+
requirements: []
|
|
180
|
+
rubygems_version: 3.3.5
|
|
181
|
+
signing_key:
|
|
182
|
+
specification_version: 4
|
|
183
|
+
summary: Puma plugin to redeploy and reload app from artifact.
|
|
184
|
+
test_files: []
|