capistrano3-puma 6.0.0.beta.1 → 6.1.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: 8d2f6376b7e7c2838e8d06d7acb249e7b4cca75982bd440e2ad8952f80941132
4
- data.tar.gz: 24ca957bc88c4f06d7a11dea7c70b72f77ca275bc46a77b6eb44f98bc51b5a3e
3
+ metadata.gz: 9d2f07d6e635bd2c3dd87706742d9f417140165102818a2f05f7be0b9d4e031d
4
+ data.tar.gz: ce613f7509c20d4520a599a0f93a9a6d5a0d485037c11aa94914fdca4c0fffcd
5
5
  SHA512:
6
- metadata.gz: e0d445a032ad196fd65b8aa863c1fb049aec6f9e8f47f22cd2d05993555c354e110bfb397d1a001b6ee0b3cb9b19e38c3d6fe76bba47d5682b17992910a5717c
7
- data.tar.gz: 9bba6960b9246b4877b02baa6339baf7a940caf16bcf54be2c0148850f96b7af1e68a07a97d03ac07bbc978275e1ea6ca44812587da942e176b674d230d2a88c
6
+ metadata.gz: c303ca5c2c0d1f28e288bffcb84ffe5ee69a708ad2c08bf000cc3f0004cdef369da1822b00b564d8c6c9e2ded34e54de7aa43a256e95384d6d7c29195a9538a1
7
+ data.tar.gz: 6750f2ae9a2c356cf1e099b5ea2e1144a6fc843bd5b9828e2843a50b15977df4e5cdc43b98216dff0bc02e40661d6934bb5a519e85734edb3a334e0a7e76a437
data/CHANGELOG.md CHANGED
@@ -1,7 +1,15 @@
1
1
  # Changelog
2
2
 
3
- [Unreleased](https://github.com/seuros/capistrano-puma/compare/v5.2.0...master)
4
- - Removed support for support for monit and upstart. (will add them back if someone is willing to maintain them)
3
+ ## [6.1.0](https://github.com/seuros/capistrano-puma/tree/6.1.0) (2025-01-21)
4
+
5
+ [Full Changelog](https://github.com/seuros/capistrano-puma/compare/v6.0.0...6.1.0)
6
+ - Restored default value for `puma_bind` to fix socket activation (Issue #387)
7
+ - Added documentation for puma.rb symlink requirement in v6.0.0 (Issue #384)
8
+ - Made WatchdogSec configurable via `puma_systemd_watchdog_sec` (Issue #373)
9
+ - Improved documentation for first-time setup and troubleshooting (Issues #377, #376, #372)
10
+ - Added migration guide for upgrading from v5 to v6
11
+ - Added troubleshooting section for common issues
12
+ - Removed support for monit and upstart (will add them back if someone is willing to maintain them)
5
13
  - Sync configuration with capistrano-sidekiq
6
14
  - Support for notify systemd service. Add sd_notify gem to your Gemfile.
7
15
  - Add example application for easier testing.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013-2022 Abdelkader Boudih
3
+ Copyright (c) 2013-2025 Abdelkader Boudih
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -15,6 +15,34 @@ And then execute:
15
15
 
16
16
  $ bundle
17
17
 
18
+ ## Upgrading from Version 5.x to 6.x
19
+
20
+ Version 6.0 includes several breaking changes:
21
+
22
+ ### Breaking Changes:
23
+ 1. **Manual Puma Configuration**: The gem no longer generates `puma.rb` automatically
24
+ - You must create your own `config/puma.rb` in your repository
25
+ - Add it to `linked_files` in your `deploy.rb`
26
+
27
+ 2. **Default puma_bind Removed**: You must explicitly set the bind address
28
+ ```ruby
29
+ set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
30
+ ```
31
+
32
+ 3. **Systemd Service Changes**: Services are now user-specific by default
33
+ - Services are created in `~/.config/systemd/user/`
34
+ - Run `cap production puma:install` again after upgrading
35
+
36
+ ### Migration Steps:
37
+ 1. Create your `config/puma.rb` if you don't have one
38
+ 2. Add to your `deploy.rb`:
39
+ ```ruby
40
+ append :linked_files, 'config/puma.rb'
41
+ set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
42
+ ```
43
+ 3. Run `cap production puma:install` to update the systemd service
44
+ 4. Deploy as normal
45
+
18
46
  ## Usage
19
47
  ```ruby
20
48
  # Capfile
@@ -43,8 +71,72 @@ To make it work with rvm, rbenv and chruby, install the plugin after correspondi
43
71
  ### Config
44
72
 
45
73
  Puma configuration is expected to be in `config/puma.rb` or `config/puma/#{fetch(:puma_env)}.rb` and checked in your repository.
46
- Uploading the configuration via capistrano was removed as it was causing problems with custom configurations.
47
74
 
75
+ Starting with version 6.0.0, you need to manage the puma configuration file yourself. Here are the steps:
76
+
77
+ 1. Create your puma configuration in `shared/config/puma.rb` on the server
78
+ 2. Add it to linked_files in your `deploy.rb`:
79
+ ```ruby
80
+ append :linked_files, 'config/puma.rb'
81
+ ```
82
+
83
+ This ensures the puma configuration persists across deployments. The systemd service will start puma with `puma -e <environment>` from your app's current directory.
84
+
85
+ ### First-Time Setup (IMPORTANT! 🎉)
86
+
87
+ **🙋 Hey there, human! Read this magical section and save yourself from confusion! 😊**
88
+
89
+ Before your first deployment, you MUST install the Puma systemd service on your server:
90
+
91
+ ```bash
92
+ # ✨ This only needs to be done once per server/stage - it's like a first date! 💝
93
+ $ bundle exec cap production puma:install
94
+ ```
95
+
96
+ This command will:
97
+ - 🏗️ Create the systemd service files for Puma
98
+ - 🚀 Enable the service to start on boot
99
+ - 🔐 Set up the proper user permissions
100
+
101
+ **🎭 Plot twist:** Without running this command first, your deployment will succeed but Puma won't start! (We know, it's sneaky like that 😅)
102
+
103
+ ### Deployment
104
+
105
+ After the initial setup, normal deployments will work as expected:
106
+ ```bash
107
+ $ bundle exec cap production deploy
108
+ ```
109
+
110
+ The deployment process will automatically restart Puma using the installed systemd service.
111
+
112
+ To manually control the Puma service:
113
+ ```bash
114
+ $ bundle exec cap production puma:start
115
+ $ bundle exec cap production puma:stop
116
+ $ bundle exec cap production puma:restart
117
+ ```
118
+
119
+ To uninstall the systemd service:
120
+ ```bash
121
+ $ bundle exec cap production puma:uninstall
122
+ ```
123
+
124
+ ### Full Task List
125
+ ```
126
+ $ cap -T puma
127
+ cap puma:disable # Disable Puma systemd service
128
+ cap puma:enable # Enable Puma systemd service
129
+ cap puma:install # Install Puma systemd service
130
+ cap puma:reload # Reload Puma service via systemd
131
+ cap puma:restart # Restart Puma service via systemd
132
+ cap puma:restart_socket # Restart Puma socket via systemd
133
+ cap puma:smart_restart # Restarts or reloads Puma service via systemd
134
+ cap puma:start # Start Puma service via systemd
135
+ cap puma:status # Get Puma service status via systemd
136
+ cap puma:stop # Stop Puma service via systemd
137
+ cap puma:stop_socket # Stop Puma socket via systemd
138
+ cap puma:uninstall # Uninstall Puma systemd service
139
+ ```
48
140
  ## Example
49
141
 
50
142
  A sample application is provided to show how to use this gem at https://github.com/seuros/capistrano-example-app
@@ -72,6 +164,8 @@ Configurable options, shown here with defaults: Please note the configuration op
72
164
  ```ruby
73
165
  set :puma_user, fetch(:user)
74
166
  set :puma_role, :web
167
+ set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
168
+ set :puma_systemd_watchdog_sec, 10 # Set to 0 or false to disable watchdog
75
169
  set :puma_service_unit_env_files, []
76
170
  set :puma_service_unit_env_vars, []
77
171
  ```
@@ -81,6 +175,35 @@ __Notes:__ If you are setting values for variables that might be used by other p
81
175
  append :rbenv_map_bins, 'puma', 'pumactl'
82
176
  ```
83
177
 
178
+ ## Troubleshooting
179
+
180
+ ### Puma is not starting after deployment
181
+ - Ensure you ran `cap production puma:install` before your first deployment
182
+ - Check the service status: `cap production puma:status`
183
+ - Check logs: `sudo journalctl -u your_app_puma_production -n 100`
184
+
185
+ ### Nginx 502 Bad Gateway errors
186
+ This usually means nginx and puma have mismatched configurations:
187
+ - If nginx expects a unix socket but puma binds to a port (or vice versa)
188
+ - Ensure your `puma_bind` in deploy.rb matches your nginx upstream configuration
189
+ - Common configurations:
190
+ ```ruby
191
+ # Unix socket (default)
192
+ set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"
193
+
194
+ # TCP port
195
+ set :puma_bind, "tcp://0.0.0.0:3000"
196
+ ```
197
+
198
+ ### Puma keeps restarting (systemd watchdog kills it)
199
+ - Your app may take longer than 10 seconds to boot
200
+ - Disable or increase WatchdogSec (requires version 6.0.0+):
201
+ ```ruby
202
+ set :puma_systemd_watchdog_sec, 30 # 30 seconds
203
+ # or
204
+ set :puma_systemd_watchdog_sec, 0 # Disable watchdog
205
+ ```
206
+
84
207
  # Nginx documentation
85
208
  Nginx documentation was moved to [nginx.md](docs/nginx.md)
86
209
 
@@ -14,6 +14,7 @@ module Capistrano
14
14
  set_if_empty :puma_systemctl_bin, -> { fetch(:systemctl_bin, '/bin/systemctl') }
15
15
  set_if_empty :puma_service_unit_name, -> { "#{fetch(:application)}_puma_#{fetch(:stage)}" }
16
16
  set_if_empty :puma_enable_socket_service, false
17
+ set_if_empty :puma_systemd_watchdog_sec, 10
17
18
 
18
19
  set_if_empty :puma_service_unit_env_files, -> { fetch(:service_unit_env_files, []) }
19
20
  set_if_empty :puma_service_unit_env_vars, -> { fetch(:service_unit_env_vars, []) }
@@ -53,7 +53,11 @@ module Capistrano
53
53
  File.expand_path("../templates/#{from}.rb.erb", __FILE__)
54
54
  ].detect { |path| File.file?(path) }
55
55
  erb = File.read(file)
56
- StringIO.new(ERB.new(erb, trim_mode: '-').result(binding))
56
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6')
57
+ StringIO.new(ERB.new(erb, nil, '-').result(binding))
58
+ else
59
+ StringIO.new(ERB.new(erb, trim_mode: '-').result(binding))
60
+ end
57
61
  end
58
62
 
59
63
  def template_puma(from, to, role)
@@ -106,6 +110,7 @@ module Capistrano
106
110
  def set_defaults
107
111
  set_if_empty :puma_role, :web
108
112
  set_if_empty :puma_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
113
+ set_if_empty :puma_bind, -> { "unix://#{File.join(shared_path, 'tmp', 'sockets', 'puma.sock')}" }
109
114
  set_if_empty :puma_access_log, -> { File.join(shared_path, 'log', "puma.log") }
110
115
  set_if_empty :puma_error_log, -> { File.join(shared_path, 'log', "puma.log") }
111
116
 
@@ -52,7 +52,7 @@ namespace :puma do
52
52
  git_plugin.execute_systemd("enable", fetch(:puma_service_unit_name) + ".socket") if fetch(:puma_enable_socket_service)
53
53
 
54
54
  if fetch(:puma_systemctl_user) != :system && fetch(:puma_enable_lingering)
55
- execute :loginctl, "enable-linger", fetch(:puma_lingering_user)
55
+ sudo "loginctl enable-linger #{fetch(:puma_lingering_user)}"
56
56
  end
57
57
  end
58
58
  end
@@ -16,7 +16,9 @@ After=syslog.target network.target
16
16
 
17
17
  [Service]
18
18
  Type=<%= service_unit_type %>
19
- WatchdogSec=10
19
+ <% if fetch(:puma_systemd_watchdog_sec) && fetch(:puma_systemd_watchdog_sec) > 0 %>
20
+ WatchdogSec=<%= fetch(:puma_systemd_watchdog_sec) %>
21
+ <% end %>
20
22
  <%="User=#{puma_user(@role)}" if fetch(:puma_systemctl_user) == :system %>
21
23
  WorkingDirectory=<%= current_path %>
22
24
  ExecStart=<%= expanded_bundle_command %> exec puma -e <%= fetch(:puma_env) %>
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano3-puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.beta.1
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-10-21 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: capistrano
@@ -95,12 +94,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
94
  version: '2.5'
96
95
  required_rubygems_version: !ruby/object:Gem::Requirement
97
96
  requirements:
98
- - - ">"
97
+ - - ">="
99
98
  - !ruby/object:Gem::Version
100
- version: 1.3.1
99
+ version: '0'
101
100
  requirements: []
102
- rubygems_version: 3.2.33
103
- signing_key:
101
+ rubygems_version: 3.6.7
104
102
  specification_version: 4
105
103
  summary: Puma integration for Capistrano
106
104
  test_files: []