puma-daemon 0.3.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/setup CHANGED
@@ -3,6 +3,6 @@ set -euo pipefail
3
3
  IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
- bundle install
6
+ BUNDLE_GEMFILE=Gemfile.puma-v5 bundle install
7
+ BUNDLE_GEMFILE=Gemfile.puma-v6 bundle install
7
8
 
8
- # Do any other automated setup that you need to do here
data/codecov.yml CHANGED
@@ -1,4 +1,34 @@
1
- comment:
2
- layout: "reach,diff,flags,tree,betaprofiling"
3
- show_critical_paths: true
1
+ codecov:
2
+ ci:
3
+ - "github.com"
4
+ max_report_age: 24
5
+ disable_default_path_fixes: no
6
+ require_ci_to_pass: yes
7
+ notify:
8
+ after_n_builds: 1
9
+ wait_for_ci: yes
10
+
11
+ github_checks:
12
+ annotations: true
13
+
14
+ coverage:
15
+ range: 50..75
16
+ round: down
17
+ precision: 2
18
+ status:
19
+ patch: false
20
+ project:
21
+ puma-daemon: # This can be anything, but it needs to exist as the name
22
+ # basic settings
23
+ target: 80%
24
+ threshold: 5%
25
+ base: auto
26
+ if_ci_failed: ignore #success, failure, error, ignore
27
+ only_pulls: false
28
+ flags:
29
+ - rspecs
30
+ paths:
31
+ - lib
32
+ informational: true
33
+ removed_code_behavior: off
4
34
 
data/example/cluster.sh CHANGED
@@ -1,39 +1,52 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- export txtblk='\e[0;30m'
4
- export txtred='\e[0;31m'
5
- export txtgrn='\e[0;32m'
6
- export txtylw='\e[0;33m'
7
- export txtblu='\e[0;34m'
8
- export txtpur='\e[0;35m'
9
- export txtcyn='\e[0;36m'
10
- export txtwht='\e[0;37m'
11
- export clr='\e[0;0m'
3
+ source colors.sh
12
4
 
13
5
  [[ -f cluster.sh ]] || {
14
6
  echo -e "${txtred}Please run this from the ./example folder.${clr}"
15
7
  exit 1
16
8
  }
17
9
 
18
- [[ -f ../Gemfile ]] || {
19
- echo -e "${txtred}Please choose either Puma v5 or Puma v6, by running:${clr}"
20
- echo -e "${txtgrn}make puma-v5 or make puma-v6"
21
- exit 2
22
- }
23
-
24
- echo -e "${txtblu}Ensuring your dependencies are installed...${clr}"
25
-
26
- (
10
+ if [[ -n "${BUNDLE_GEMFILE}" || -f ../Gemfile ]]; then
11
+ echo -e "${txtgrn}OK: We have either BUNDLE_GEMFILE defined or ../Gemfile"
12
+ [[ -z $BUNDLE_GEMFILE ]] && BUNDLE_GEMFILE=Gemfile
13
+ else
14
+ export BUNDLE_GEMFILE=Gemfile.puma-v6
15
+ echo -e "${txtylw}WARNING: Set BUNDLE_GEMFILE to either v5 or v6."
16
+ echo -e "${txtylw} Since none we set, we selected v6 for now."
17
+ sleep 2
18
+ fi
19
+
20
+ export GEMFILE=${BUNDLE_GEMFILE}
21
+
22
+ if [[ -z ${GEMFILE} || ! -f "${GEMFILE}" ]]; then
23
+ export GEMFILE="../${BUNDLE_GEMFILE}"
24
+ [[ -f ${GEMFILE} ]] || {
25
+ echo -e "${txtred}ERROR: File [${GEMFILE}] does not exist ${clr}"
26
+ exit 3
27
+ }
28
+ fi
29
+
30
+ echo -e "${txtylw}Using GEMFILE: ${txtgrn}[${GEMFILE}]${clr}"
31
+ echo -e "${txtylw}Installing Bundled Gems...${clr}"
32
+
33
+ (
27
34
  cd .. || exit 2;
35
+ export BUNDLE_GEMFILE=${BUNDLE_GEMFILE:-"Gemfile"} ;
28
36
  bundle check || bundle install
29
37
  ) >/dev/null
30
38
 
39
+ echo -e "${txtblu}Ensuring your dependencies are installed...${clr}"
40
+ sleep 1
41
+
31
42
  pid=$(ps -ef | grep puma | grep example | awk '{print $2}')
32
43
 
33
44
  [[ -n $pid ]] && kill $pid && sleep 1
34
45
 
35
46
  echo -e "${txtblu}Starting Puma in cluster mode.${clr}"
36
47
 
48
+ export BUNDLE_GEMFILE=$GEMFILE
49
+
37
50
  command="bundle exec puma -I ../lib -C $(pwd)/puma.rb -w 4"
38
51
  echo -e "${txtblu}Running Command:"
39
52
  echo -e "${txtgrn}${command}${clr}"
@@ -55,7 +68,15 @@ curl http://0.0.0.0:9292/ > "${output}" 2>/dev/null
55
68
  exit 3
56
69
  }
57
70
 
58
- echo -e "${txtgrn}Puma Daemon is running and returning the expected string.${clr}"
71
+ echo -e "${txtblu}Currently Running Puma Processes:${txtcyn}"
72
+
73
+ ps auxww | grep [p]uma
74
+
75
+ echo
76
+ echo -e "${txtgrn}┌─────────────────────────────────────────────────────────────────────────┐"
77
+ echo -e "${txtgrn}│ Puma Daemon is UP in the CLUSTER/WORKERS mode & HTTP response is 200/OK │"
78
+ echo -e "${txtgrn}└─────────────────────────────────────────────────────────────────────────┘${clr}"
79
+ echo
80
+
59
81
 
60
- ps -ef | grep [p]uma
61
82
 
data/example/colors.sh ADDED
@@ -0,0 +1,11 @@
1
+
2
+ export txtblk='\e[0;30m'
3
+ export txtred='\e[0;31m'
4
+ export txtgrn='\e[0;32m'
5
+ export txtylw='\e[0;33m'
6
+ export txtblu='\e[0;34m'
7
+ export txtpur='\e[0;35m'
8
+ export txtcyn='\e[0;36m'
9
+ export txtwht='\e[0;37m'
10
+ export clr='\e[0;0m'
11
+
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bash
2
+
3
+ source colors.sh
4
+
5
+ # Kill any process matching "puma" in the name
6
+ declare -a pids
7
+ pids=( $(ps -ef | grep [p]uma | grep -v puma: | grep -v kill-puma | grep -v grep | awk '{print $2}') )
8
+
9
+ echo -e "${txtgrn}Currently running Puma Processes:${clr}"
10
+ echo -e "${txtylw}"
11
+ ps -ef | grep [p]uma | grep -v kill-puma
12
+ echo -en "${clr}"
13
+ if [[ -z ${pids[*]} ]] ; then
14
+ echo -e "${txtred}No puma processes were found, nothing to kill.${clr}"
15
+ else
16
+ echo "Found the following pids matching Puma: [${pids[*]}]"
17
+ echo "Let the killing commence..."
18
+ for pid in "${pids[@]}"; do
19
+ [[ -n $(ps -p $pid) ]] && {
20
+ echo "killing $pid..."
21
+ kill $pid 2>/dev/null
22
+ }
23
+ done
24
+ sleep 1
25
+ for pid in "${pids[@]}"; do
26
+ [[ -n $(ps -p $pid) ]] && {
27
+ echo "nuking $pid..."
28
+ kill -9 $pid 2>/dev/null
29
+ }
30
+ done
31
+ fi
32
+
data/example/single.sh CHANGED
@@ -1,14 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- export txtblk='\e[0;30m'
4
- export txtred='\e[0;31m'
5
- export txtgrn='\e[0;32m'
6
- export txtylw='\e[0;33m'
7
- export txtblu='\e[0;34m'
8
- export txtpur='\e[0;35m'
9
- export txtcyn='\e[0;36m'
10
- export txtwht='\e[0;37m'
11
- export clr='\e[0;0m'
3
+ source colors.sh
12
4
 
13
5
  [[ -f single.sh ]] || {
14
6
  echo -e "${txtred}Please run this from the ./example folder.${clr}"
@@ -23,7 +15,7 @@ export clr='\e[0;0m'
23
15
 
24
16
  echo -e "${txtblu}Ensuring your dependencies are installed...${clr}"
25
17
 
26
- (
18
+ (
27
19
  cd .. || exit 2;
28
20
  bundle check || bundle install
29
21
  ) >/dev/null
@@ -55,10 +47,15 @@ curl http://0.0.0.0:9292/ > "${output}" 2>/dev/null
55
47
  exit 3
56
48
  }
57
49
 
58
- echo -e "${txtgrn}Puma Daemon is running and returning the expected string.${clr}"
50
+ echo -e "${txtblu} Currently Running Puma Processes:$clr"
59
51
 
60
- ps -ef | grep [p]uma
52
+ ps auxww | grep [p]uma
61
53
 
62
54
  echo
55
+ echo -e "${txtgrn}┌────────────────────────────────────────────────────────────────────────┐"
56
+ echo -e "${txtgrn}│ Puma Daemon is UP in the Single Process mode & HTTP response is 200/OK │"
57
+ echo -e "${txtgrn}└────────────────────────────────────────────────────────────────────────┘${clr}"
58
+ echo
59
+
63
60
 
64
61
 
@@ -5,7 +5,7 @@ module Puma
5
5
  module Configuration
6
6
  attr_reader :default_dsl, :file_dsl, :user_dsl
7
7
 
8
- def puma_default_options
8
+ def puma_default_options(*args, **opts, &block)
9
9
  super.merge({ daemon: true })
10
10
  end
11
11
 
@@ -4,6 +4,7 @@ require_relative 'version'
4
4
 
5
5
  module Puma
6
6
  module Daemon
7
+ # noinspection RubySuperCallWithoutSuperclassInspection
7
8
  module RunnerAdapter
8
9
  class << self
9
10
  def included(base)
@@ -14,7 +15,7 @@ module Puma
14
15
 
15
16
  base.class_eval do
16
17
  def output_header(mode)
17
- super(mode)
18
+ super
18
19
 
19
20
  daemonize! if daemon?
20
21
  end
@@ -35,10 +36,10 @@ module Puma
35
36
  end
36
37
 
37
38
  def log(str)
38
- return if str =~ /Ctrl-C/
39
+ return if str.include?('Ctrl-C')
39
40
 
40
41
  begin
41
- super(str)
42
+ super
42
43
  rescue StandardError
43
44
  puts(str)
44
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Puma
4
4
  module Daemon
5
- VERSION = '0.3.2'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
data/puma-daemon.gemspec CHANGED
@@ -11,10 +11,10 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Restore somewhat Puma's ability to self-daemonize, since Puma 5.0 dropped it"
12
12
  spec.description = <<~DESCRIPTION
13
13
 
14
- In version 5.0 the authors of the popular Ruby web server Puma chose to remove the
14
+ In version 5.0 the authors of the popular Ruby web server Puma chose to remove the#{' '}
15
15
  daemonization support from Puma, because the code wasn't wall maintained,
16
16
  and because other and better options exist for production deployments. For example
17
- systemd, Docker/Kubernetes, Heroku, etc.
17
+ systemd, Docker/Kubernetes, Heroku, etc.#{' '}
18
18
 
19
19
  Having said that, it was neat and often useful to daemonize Puma in development.
20
20
  This gem adds this support to Puma 5 & 6 (hopefully) without breaking anything in Puma
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.homepage = 'https://github.com/kigster/puma-daemon'
28
28
  spec.license = 'MIT'
29
29
 
30
- spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
30
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6')
31
31
 
32
32
  spec.metadata['homepage_uri'] = spec.homepage
33
33
  spec.metadata['source_code_uri'] = 'https://github.com/kigster/puma-daemon'
@@ -46,15 +46,6 @@ Gem::Specification.new do |spec|
46
46
  spec.add_dependency 'puma', '>= 5.0'
47
47
  spec.add_dependency 'rack'
48
48
 
49
- spec.add_development_dependency 'asciidoctor'
50
- spec.add_development_dependency 'codecov'
51
- spec.add_development_dependency 'httparty'
52
- spec.add_development_dependency 'relaxed-rubocop'
53
- spec.add_development_dependency 'rspec-its'
54
- spec.add_development_dependency 'rubocop'
55
- spec.add_development_dependency 'simplecov'
56
- spec.add_development_dependency 'yard'
57
-
58
49
  # For more information and examples about making a new gem, checkout our
59
50
  # guide at: https://bundler.io/guides/creating_gem.html
60
51
  spec.metadata['rubygems_mfa_required'] = 'true'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-daemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-22 00:00:00.000000000 Z
11
+ date: 2024-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -38,118 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: asciidoctor
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: codecov
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
- - !ruby/object:Gem::Dependency
70
- name: httparty
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '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'
83
- - !ruby/object:Gem::Dependency
84
- name: relaxed-rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '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'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec-its
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: simplecov
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: yard
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
41
  description: "\nIn version 5.0 the authors of the popular Ruby web server Puma chose
154
42
  to remove the \ndaemonization support from Puma, because the code wasn't wall maintained,\nand
155
43
  because other and better options exist for production deployments. For example\nsystemd,
@@ -166,6 +54,7 @@ extensions: []
166
54
  extra_rdoc_files: []
167
55
  files:
168
56
  - ".envrc"
57
+ - ".github/workflows/license.yml"
169
58
  - ".github/workflows/main.yml"
170
59
  - ".gitignore"
171
60
  - ".rspec"
@@ -175,7 +64,9 @@ files:
175
64
  - Dockerfile.build
176
65
  - Dockerfile.download
177
66
  - Gemfile.puma-v5
67
+ - Gemfile.puma-v5.lock
178
68
  - Gemfile.puma-v6
69
+ - Gemfile.puma-v6.lock
179
70
  - LICENSE.txt
180
71
  - Makefile
181
72
  - README.adoc
@@ -187,7 +78,9 @@ files:
187
78
  - config/puma_cluster.rb
188
79
  - config/puma_single.rb
189
80
  - example/cluster.sh
81
+ - example/colors.sh
190
82
  - example/config.ru
83
+ - example/kill-puma.sh
191
84
  - example/puma.rb
192
85
  - example/single.sh
193
86
  - exe/pumad
@@ -215,14 +108,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
108
  requirements:
216
109
  - - ">="
217
110
  - !ruby/object:Gem::Version
218
- version: 2.4.0
111
+ version: '2.6'
219
112
  required_rubygems_version: !ruby/object:Gem::Requirement
220
113
  requirements:
221
114
  - - ">="
222
115
  - !ruby/object:Gem::Version
223
116
  version: '0'
224
117
  requirements: []
225
- rubygems_version: 3.4.13
118
+ rubygems_version: 3.5.21
226
119
  signing_key:
227
120
  specification_version: 4
228
121
  summary: Restore somewhat Puma's ability to self-daemonize, since Puma 5.0 dropped