mina-ng-puma 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 252dc65fd614942078f9e648b52052e03bd900c5e6c62ac42eb3d78d62987c6d
4
- data.tar.gz: e753421c3578992fc2c2cf71512e3175a06de2308180486747b7c1184ee8080d
3
+ metadata.gz: 8fb27c66f43bd929905dc3630f3341306ecfce266da35d7d50ab17e8aeadb046
4
+ data.tar.gz: 71f618ff61cffebf415d091ed31d70ca8d86db892334bfa283d95dfa7dce2ada
5
5
  SHA512:
6
- metadata.gz: ebba072ded0c6c466c2bae792c3ce838c2a41929716a66e0451a4147ba5a9edb851bca1ac30604a10680eac704ca6c3de510b1b562f6f0c906c24cfee623467e
7
- data.tar.gz: 61552a2aa2cee1d2782b556daa63c558b607d5e522f81417794db3cc0af49489a0cd0c07fb2d34f99c7656c56296de938191d0530d423edc34ecc89355b76b2c
6
+ metadata.gz: c6dcf8e41babc457858a989283635548bd66c38047fd2e71a45eed74ab5f415f4a108a2fae78ea94ef018b5766ea66076c467f53a1a246a4fddfc12c8fb23395
7
+ data.tar.gz: d72773a861a9b2e226837bf9bb5887029de713b4fda9e818426fb604e4c02c26ad754c03e2a67243eaca254f9a9c1294574c7a4489e7fedae5f53fb3a940bd86
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Tobias Sandelius
1
+ Copyright (c) 2019 WinDy
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -4,13 +4,14 @@ I refactor mina-puma( https://github.com/untitledkingdom/mina-puma ) because of
4
4
 
5
5
  1. `phased_restart` and `restart` need start puma correctly when puma is down.
6
6
  2. `phased_restart` and `restart` should confirm puma restart successfully.
7
- 3. check `puma_pid` instead of `pumactl_socket`.
7
+ 3. Add `smart_restart` mode, it will first try to do `phased_restart`, when failed, using `hard_restart` instead.
8
8
 
9
9
  [Mina](https://github.com/nadarei/mina) tasks for handle with
10
10
  [Puma](https://github.com/puma/puma).
11
11
 
12
12
  This gem provides several mina tasks:
13
13
 
14
+ mina puma:smart_restart # Restart puma ( phased_restart then hard_restart )
14
15
  mina puma:phased_restart # Restart puma (using phased restart)
15
16
  mina puma:hard_restart # Restart puma (using stop, then start)
16
17
  mina puma:restart # Restart puma (using pumactl)
@@ -20,7 +21,7 @@ This gem provides several mina tasks:
20
21
 
21
22
  ## Installation
22
23
 
23
- Add this line to your application's Gemfile:
24
+ Add this line to your Rails application's Gemfile:
24
25
 
25
26
  gem 'mina-ng-puma', require: false
26
27
 
@@ -28,11 +29,10 @@ And then execute:
28
29
 
29
30
  $ bundle
30
31
 
31
- Or install it yourself as:
32
+ Note: You should remove `mina-puma` gem to ignore namespace conflict if you have install it before.
32
33
 
33
- $ gem install mina-ng-puma
34
+ $ gem uninstall mina-puma
34
35
 
35
- 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.
36
36
 
37
37
  ## Usage
38
38
 
@@ -86,7 +86,7 @@ task :deploy do
86
86
 
87
87
  on :launch do
88
88
  ...
89
- invoke :'puma:phased_restart'
89
+ invoke :'puma:smart_restart'
90
90
  end
91
91
  end
92
92
  end
@@ -50,19 +50,36 @@ namespace :puma do
50
50
 
51
51
  desc 'Restart puma (phased restart)'
52
52
  task :phased_restart do
53
- comment "Restart Puma -- phased..."
53
+ comment "Restart Puma -- phased mode..."
54
54
  pumactl_restart_command 'phased-restart'
55
55
  wait_phased_restart_successful_command
56
56
  end
57
57
 
58
58
  desc 'Restart puma (hard restart)'
59
59
  task :hard_restart do
60
- comment "Restart Puma -- hard..."
60
+ comment "Restart Puma -- hard mode..."
61
61
  invoke 'puma:stop'
62
62
  wait_quit_or_force_quit_command
63
63
  invoke 'puma:start'
64
64
  end
65
65
 
66
+ desc 'Restart puma (smart restart)'
67
+ task :smart_restart do
68
+ comment "Restart Puma -- smart mode..."
69
+ comment "Trying phased restart..."
70
+ pumactl_restart_command 'phased-restart'
71
+ hard_restart_script = %{
72
+ echo "Phased-restart have failed, using hard-restart mode instead..." \n
73
+ }
74
+ # TODO: refactor it when we have better method
75
+ # hacking in mina commands.process to get hard_restart script
76
+ on :puma_smart_restart_tmp do
77
+ invoke 'puma:hard_restart'
78
+ hard_restart_script += commands.process
79
+ end
80
+ wait_phased_restart_successful_command(60, hard_restart_script)
81
+ end
82
+
66
83
  desc 'Get status of puma'
67
84
  task :status do
68
85
  comment "Puma status..."
@@ -110,10 +127,15 @@ namespace :puma do
110
127
  command cmd
111
128
  end
112
129
 
113
- def wait_phased_restart_successful_command
130
+ def wait_phased_restart_successful_command(default_times = 120, exit_script = nil)
131
+ default_exit_script = %{
132
+ echo "Please check it manually!!!"
133
+ exit 1
134
+ }
135
+ exit_script ||= default_exit_script
114
136
  cmd = %{
115
137
  started_flag=false
116
- default_times=120
138
+ default_times=#{default_times}
117
139
  times=$default_times
118
140
  cd #{fetch(:puma_root_path)}
119
141
  echo "Waiting phased-restart finish( default: $default_times seconds)..."
@@ -138,8 +160,8 @@ namespace :puma do
138
160
  done
139
161
 
140
162
  if [ $started_flag == false ]; then
141
- echo "Waiting phased-restart timeout(default: $default_times seconds), please check it!!!"
142
- exit 1
163
+ echo "Waiting phased-restart timeout(default: $default_times seconds)..."
164
+ #{exit_script}
143
165
  else
144
166
  echo "Phased-restart have finished, enjoy it!"
145
167
  fi
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Puma
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-ng-puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - windy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2019-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mina
@@ -101,8 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.7.6
104
+ rubygems_version: 3.0.3
106
105
  signing_key:
107
106
  specification_version: 4
108
107
  summary: Next Generation Puma tasks for Mina