mina-puma-systemd 1.0.0
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/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +93 -0
- data/Rakefile +1 -0
- data/lib/mina/puma_systemd/tasks.rake +63 -0
- data/lib/mina/puma_systemd/version.rb +5 -0
- data/lib/mina/puma_systemd.rb +1 -0
- data/mina-puma-systemd.gemspec +26 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bba706a63a92692726ff2c26bc07b9efa79dfdedcdd7c8420be8e20989f9ddb6
|
4
|
+
data.tar.gz: ee45eb3521f66d81a63858f529ff1fd60435cdb05d852bf20d0b9da25cde1865
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91415fd1f025faf1fd81695c98fa2334adb254abb3266e405870d1d3d4b1129cb09a0e5438495a7b0408f2a0a6271d764d8cd0e57a76077c99919e030961408a
|
7
|
+
data.tar.gz: 26568e17afaeced834e2e5f71c22c502c53475d2ad441692ee0172315effd2438e380c23854e3ca760c75765f2a96c7fb605fe3364174051b61e18e6dc5bad67
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tobias Sandelius
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Mina Puma
|
2
|
+
|
3
|
+
[Mina](https://github.com/mina-deploy/mina) tasks for handle with
|
4
|
+
[Puma](https://github.com/puma/puma) using [systemd](https://systemd.io).
|
5
|
+
|
6
|
+
This gem provides several mina tasks:
|
7
|
+
|
8
|
+
mina puma:reload # Restart puma (using phased restart)
|
9
|
+
mina puma:restart # Restart puma (using stop, then start)
|
10
|
+
mina puma:start # Start puma
|
11
|
+
mina puma:stop # Stop puma
|
12
|
+
mina puma:status # Get status
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'mina-puma-systemd', require: false
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Note: by just including this gem, does not mean your development server will be Puma, for that, you need explicitly add `gem 'puma'` to your Gemfile and configure it.
|
25
|
+
This gem does not (yet) create puma and systemd service config files, you have to do it manually.
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Add this to your `config/deploy.rb` file:
|
30
|
+
|
31
|
+
require 'mina/puma-systemd'
|
32
|
+
|
33
|
+
Make sure the following settings are set in your `config/deploy.rb`:
|
34
|
+
|
35
|
+
* `deploy_to` - deployment path
|
36
|
+
* `rails_env` - rails environement (will default to `production`)
|
37
|
+
|
38
|
+
Make sure the following directories exists on your server (they are added automatically to `shared_dirs`:
|
39
|
+
|
40
|
+
* `shared/tmp/sockets` - directory for socket files.
|
41
|
+
* `shared/tmp/pids` - directory for pid files.
|
42
|
+
|
43
|
+
You can tweak some settings:
|
44
|
+
|
45
|
+
* `puma_systemctl` - systemctl command, default is ` sudo systemctl`. Other option would be `systemctl --user` if you have setup pumas as user service.
|
46
|
+
* `puma_service_name` - puma service name , default is `puma_#{fetch(:application_name)}_#{fetch(:puma_env)}`
|
47
|
+
|
48
|
+
|
49
|
+
Then:
|
50
|
+
|
51
|
+
```
|
52
|
+
$ mina puma:start
|
53
|
+
```
|
54
|
+
|
55
|
+
## Example
|
56
|
+
```ruby
|
57
|
+
require 'mina/puma-systemd'
|
58
|
+
|
59
|
+
task :deploy do
|
60
|
+
deploy do
|
61
|
+
invoke :'git:clone'
|
62
|
+
invoke :'deploy:link_shared_paths'
|
63
|
+
...
|
64
|
+
|
65
|
+
on :launch do
|
66
|
+
...
|
67
|
+
invoke :'puma:reload'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
## sudo configuration
|
74
|
+
By default plugin relies on sudo to run systemctl command. You should give proper permissions to the user which runs your app.
|
75
|
+
```bash
|
76
|
+
Cmnd_Alias SERVICES = /usr/bin/systemctl start *, /usr/bin/systemctl stop *, /usr/bin/systemctl reload *, /usr/bin/systemctl restart *, /usr/bin/systemctl status *, /usr/bin/systemctl enable *, /usr/bin/systemctl disable *
|
77
|
+
deploy ALL=(ALL) NOPASSWD: SERVICES
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
If you are paranoid, substitute `*` with exact service name. Better option would be to run as user service, but it did not work for me out of box on AWS AMI2.
|
82
|
+
|
83
|
+
## TODO
|
84
|
+
* Generate and upload puma.rb file
|
85
|
+
* Generate and upload puma systemd service
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
1. Fork it
|
90
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
92
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
93
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'mina/bundler'
|
2
|
+
require 'mina/rails'
|
3
|
+
|
4
|
+
namespace :puma do
|
5
|
+
set :shared_dirs, fetch(:shared_dirs, []).push("tmp/sockets", "tmp/pids")
|
6
|
+
|
7
|
+
set :puma_role, -> { fetch(:user) }
|
8
|
+
set :puma_env, -> { fetch(:rails_env, 'production') }
|
9
|
+
set :puma_root_path, -> { fetch(:current_path) }
|
10
|
+
|
11
|
+
set :puma_systemctl, -> { fetch(:systemctl, "sudo systemctl")}
|
12
|
+
set :puma_service_name, -> { "puma_#{fetch(:application_name)}_#{fetch(:puma_env)}" }
|
13
|
+
|
14
|
+
desc 'Enable puma'
|
15
|
+
task enable: :remote_environment do
|
16
|
+
comment "Enabling Puma..."
|
17
|
+
command "#{fetch(:puma_systemctl)} enable #{fetch(:puma_service_name)}"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Disable puma'
|
21
|
+
task start: :remote_environment do
|
22
|
+
comment "Enabling Puma..."
|
23
|
+
command "#{fetch(:puma_systemctl)} disable #{fetch(:puma_service_name)}"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Start puma'
|
27
|
+
task start: :remote_environment do
|
28
|
+
comment "Starting Puma..."
|
29
|
+
command "#{fetch(:puma_systemctl)} start #{fetch(:puma_service_name)}"
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Stop puma'
|
33
|
+
task stop: :remote_environment do
|
34
|
+
comment "Stopping Puma..."
|
35
|
+
command "#{fetch(:puma_systemctl)} stop #{fetch(:puma_service_name)}"
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Restart puma'
|
39
|
+
task restart: :remote_environment do
|
40
|
+
comment "Restart Puma...."
|
41
|
+
command "#{fetch(:puma_systemctl)} restart #{fetch(:puma_service_name)}"
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Reload puma (phased restart)'
|
45
|
+
task reload: :remote_environment do
|
46
|
+
command %[
|
47
|
+
if #{fetch(:puma_systemctl)} is-active --quiet #{fetch(:puma_service_name)} ; then
|
48
|
+
echo "Reload Puma -- phased..."
|
49
|
+
#{fetch(:puma_systemctl)} reload #{fetch(:puma_service_name)}
|
50
|
+
else
|
51
|
+
echo "Starting Puma..."
|
52
|
+
#{fetch(:puma_systemctl)} start #{fetch(:puma_service_name)}
|
53
|
+
fi
|
54
|
+
]
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'Get status of puma'
|
58
|
+
task status: :remote_environment do
|
59
|
+
comment "Puma status..."
|
60
|
+
command "#{fetch(:puma_systemctl)} status -l #{fetch(:puma_service_name)}"
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../puma/tasks.rake", __FILE__)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mina/puma_systemd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'mina-puma-systemd'
|
8
|
+
spec.version = Mina::PumaSystemd::VERSION
|
9
|
+
spec.authors = ['Vladimir Elchinov']
|
10
|
+
spec.email = ['elik@elik.ru']
|
11
|
+
spec.description = %q{Puma tasks for Mina and systemd}
|
12
|
+
spec.summary = %q{Puma tasks for Mina and systemd}
|
13
|
+
spec.homepage = 'https://github.com/railsblueprint/mina-puma-systemd'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'mina', '~> 1.2.0'
|
22
|
+
spec.add_dependency 'puma', '>= 2.13'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mina-puma-systemd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vladimir Elchinov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mina
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: puma
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.13'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Puma tasks for Mina and systemd
|
70
|
+
email:
|
71
|
+
- elik@elik.ru
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/mina/puma_systemd.rb
|
82
|
+
- lib/mina/puma_systemd/tasks.rake
|
83
|
+
- lib/mina/puma_systemd/version.rb
|
84
|
+
- mina-puma-systemd.gemspec
|
85
|
+
homepage: https://github.com/railsblueprint/mina-puma-systemd
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubygems_version: 3.0.3
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Puma tasks for Mina and systemd
|
108
|
+
test_files: []
|