pixelforce_recipes 1.6 → 2.3

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.
Files changed (27) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile.lock +12 -12
  3. data/README.md +33 -1
  4. data/lib/pixelforce_recipes/capistrano_3_recipes/puma.rb +55 -11
  5. data/lib/pixelforce_recipes/capistrano_3_recipes/resque.rb +32 -11
  6. data/lib/pixelforce_recipes/capistrano_3_recipes/resque_scheduler.rb +32 -11
  7. data/lib/pixelforce_recipes/capistrano_3_recipes/sidekiq.rb +65 -11
  8. data/lib/pixelforce_recipes/capistrano_3_recipes/supervisor.rb +9 -0
  9. data/lib/pixelforce_recipes/capistrano_3_recipes/unicorn.rb +47 -13
  10. data/lib/pixelforce_recipes/templates/logrotate.erb +5 -3
  11. data/lib/pixelforce_recipes/templates/nginx_config.erb +4 -1
  12. data/lib/pixelforce_recipes/templates/nginx_puma_config.erb +3 -4
  13. data/lib/pixelforce_recipes/templates/puma.rb.erb +34 -0
  14. data/lib/pixelforce_recipes/templates/puma_init.erb +4 -4
  15. data/lib/pixelforce_recipes/templates/puma_supervisor.erb +13 -0
  16. data/lib/pixelforce_recipes/templates/resque_init.erb +2 -2
  17. data/lib/pixelforce_recipes/templates/resque_scheduler_init.erb +2 -2
  18. data/lib/pixelforce_recipes/templates/resque_scheduler_supervisor.erb +13 -0
  19. data/lib/pixelforce_recipes/templates/resque_supervisor.erb +13 -0
  20. data/lib/pixelforce_recipes/templates/sidekiq_init.erb +1 -1
  21. data/lib/pixelforce_recipes/templates/sidekiq_supervisor.erb +12 -0
  22. data/lib/pixelforce_recipes/templates/supervisor.erb +19 -0
  23. data/lib/pixelforce_recipes/templates/unicorn_supervisor.erb +13 -0
  24. data/lib/pixelforce_recipes/version.rb +1 -1
  25. data/lib/pixelforce_recipes.rb +3 -13
  26. data/pixelforce_recipes.gemspec +1 -1
  27. metadata +16 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 64f4526b060f50034f0c162a5eba31076fd6ef5e
4
- data.tar.gz: 0d3241f33aefabbd1a6ba449f52ab5b269bff811
2
+ SHA256:
3
+ metadata.gz: ad9d77ec9bf9d8ffe4eabde0ee7813cd2d8f900584b2908cb628658bc93261a1
4
+ data.tar.gz: 37927ba6a5f7ebf744331a2e2f6829538db140eedce42ae118d6b0db82393249
5
5
  SHA512:
6
- metadata.gz: 62053ca4fce227f367dfb66eaa834f2a68582af12603b8eabbbb14c3d2645f01e399c694d11f9637a4de980a68991d40599552d0279eaa4907b54366aa44e53e
7
- data.tar.gz: 820c96d215832f9073b4df3c3ebe67e917bc1e2c530244c0ac429fbeb35c6292ec9d1e2c6992d48946fe60208cefc51b5420c04118a4047fe3b4cf0b9be33287
6
+ metadata.gz: b855a9ead01e7808631d853bbed9a278661439597910b97bd75b175bd7a4ff22fdbf9508a693669645ee2f7d38e2100b73ac9b151cc88a1fcc9d29a263407b2a
7
+ data.tar.gz: e244b96ca0385bf32fb349b0506728ac1c9bb41003e6a884aefd110fc7a2b7aff4d047631250d95236325d0c0226e0542df99f0bed2f71f97f9c6d2faf4a4016
data/Gemfile.lock CHANGED
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixelforce_recipes (1.6)
4
+ pixelforce_recipes (2.3)
5
5
  capistrano (> 2.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- airbrussh (1.3.0)
10
+ airbrussh (1.4.0)
11
11
  sshkit (>= 1.6.1, != 1.7.0)
12
- capistrano (3.11.0)
12
+ capistrano (3.16.0)
13
13
  airbrussh (>= 1.0.0)
14
14
  i18n
15
15
  rake (>= 10.0.0)
16
16
  sshkit (>= 1.9.0)
17
- concurrent-ruby (1.1.4)
17
+ concurrent-ruby (1.1.9)
18
18
  diff-lcs (1.2.5)
19
- i18n (1.4.0)
19
+ i18n (1.8.10)
20
20
  concurrent-ruby (~> 1.0)
21
- net-scp (1.2.1)
22
- net-ssh (>= 2.6.5)
23
- net-ssh (5.0.2)
24
- rake (10.5.0)
21
+ net-scp (3.0.0)
22
+ net-ssh (>= 2.6.5, < 7.0.0)
23
+ net-ssh (6.1.0)
24
+ rake (13.0.1)
25
25
  rspec (3.5.0)
26
26
  rspec-core (~> 3.5.0)
27
27
  rspec-expectations (~> 3.5.0)
@@ -35,7 +35,7 @@ GEM
35
35
  diff-lcs (>= 1.2.0, < 2.0)
36
36
  rspec-support (~> 3.5.0)
37
37
  rspec-support (3.5.0)
38
- sshkit (1.17.0)
38
+ sshkit (1.21.2)
39
39
  net-scp (>= 1.1.2)
40
40
  net-ssh (>= 2.8.0)
41
41
 
@@ -45,8 +45,8 @@ PLATFORMS
45
45
  DEPENDENCIES
46
46
  bundler (~> 1.12)
47
47
  pixelforce_recipes!
48
- rake (~> 10.0)
48
+ rake (~> 13.0)
49
49
  rspec (~> 3.0)
50
50
 
51
51
  BUNDLED WITH
52
- 1.15.0
52
+ 1.17.3
data/README.md CHANGED
@@ -34,8 +34,40 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
34
 
35
35
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pixelforce_recipes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
36
 
37
+ ## supervisor support
38
+
39
+ The recipes for capistrano3 with supervisor support.
40
+ Please use `process:supervisor:task` to invoke it.
41
+ They relied on some capistrano plugins for some variables
42
+
43
+ * [**rvm**](https://github.com/capistrano/rvm) for `rvm_ruby_version`
44
+
45
+ Tweak some option for supervisor, the following value is default
46
+
47
+ ```ruby
48
+ set :autostart, 'true'
49
+ set :autorestart, 'true'
50
+ set :logfile_maxbytes, '1GB'
51
+ set :logfile_backups, '10'
52
+ ```
53
+
54
+ #### unicorn
55
+
56
+ Relied on unicornherder for supervisor monitoring.
57
+
58
+ #### puma
59
+
60
+ Get rid of capistrano-puma, and now generate puma config itself.
61
+
62
+ ```ruby
63
+ set :puma_threads, [0, 1]
64
+ set :puma_workers, 2
65
+ ```
66
+
67
+ ## sysvinit support
68
+
69
+ Please use `process:sysvinit:task` to invoke it.
37
70
 
38
71
  ## License
39
72
 
40
73
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -1,22 +1,66 @@
1
1
  namespace :puma do
2
2
 
3
3
  desc "Setup puma configuration for this application"
4
- task :setup do
4
+ task :config do
5
5
  on roles(:web) do
6
- template "puma_init.erb", "/tmp/puma"
7
- sudo "mv /tmp/puma /etc/init.d/#{fetch(:application)}"
8
- sudo "chmod +x /etc/init.d/#{fetch(:application)}"
9
- sudo "update-rc.d #{fetch(:application)} defaults"
10
- template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
11
- sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
6
+ template "puma.rb.erb", "/tmp/puma_conf"
7
+ sudo "mv /tmp/puma_conf #{shared_path}/config/puma.rb"
8
+ execute "mkdir -p #{shared_path}/pids"
12
9
  end
13
10
  end
14
11
 
15
- %w[start stop restart].each do |command|
16
- desc "#{command} puma"
17
- task command do
12
+ namespace :sysvinit do
13
+ task :setup do
18
14
  on roles(:web) do
19
- execute "/etc/init.d/#{fetch(:application)} #{command}"
15
+ template "puma_init.erb", "/tmp/puma"
16
+ sudo "mv /tmp/puma /etc/init.d/#{fetch(:application)}"
17
+ sudo "chmod +x /etc/init.d/#{fetch(:application)}"
18
+ sudo "update-rc.d #{fetch(:application)} defaults"
19
+ template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
20
+ sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
21
+ end
22
+ end
23
+
24
+ %w[start stop restart reload].each do |command|
25
+ desc "#{command} puma"
26
+ task command do
27
+ on roles(:web) do
28
+ execute "/etc/init.d/#{fetch(:application)} #{command}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ namespace :supervisor do
35
+ task :setup do
36
+ on roles(:web) do
37
+ template "puma_supervisor.erb", "/tmp/puma"
38
+ sudo "mv /tmp/puma /etc/supervisor/conf.d/#{fetch(:application)}.conf"
39
+ sudo "supervisorctl reread"
40
+ sudo "supervisorctl update" # it will auto start the application
41
+ template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
42
+ sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
43
+ end
44
+ end
45
+
46
+ task :start do
47
+ on roles(:web) do
48
+ execute "supervisorctl start #{fetch(:application)}"
49
+ end
50
+ end
51
+ task :stop do
52
+ on roles(:web) do
53
+ execute "supervisorctl signal INT #{fetch(:application)}"
54
+ end
55
+ end
56
+ task :restart do
57
+ on roles(:web) do
58
+ execute "supervisorctl signal USR1 #{fetch(:application)}"
59
+ end
60
+ end
61
+ task :reload do
62
+ on roles(:web) do
63
+ execute "supervisorctl signal USR2 #{fetch(:application)}"
20
64
  end
21
65
  end
22
66
  end
@@ -2,20 +2,41 @@ namespace :resque do
2
2
  desc "Install resque"
3
3
 
4
4
  desc "Setup resque configuration for this application"
5
- task :setup do
6
- on roles(:resque) do
7
- template "resque_init.erb", "/tmp/resque"
8
- sudo "mv /tmp/resque /etc/init.d/resque"
9
- sudo "chmod +x /etc/init.d/resque"
10
- sudo "update-rc.d resque defaults"
5
+ namespace :sysvinit do
6
+ task :setup do
7
+ on roles(:resque) do
8
+ template "resque_init.erb", "/tmp/resque"
9
+ sudo "mv /tmp/resque /etc/init.d/resque"
10
+ sudo "chmod +x /etc/init.d/resque"
11
+ sudo "update-rc.d resque defaults"
12
+ end
11
13
  end
12
- end
13
14
 
14
- %w[start stop restart].each do |command|
15
- desc "#{command} resque"
16
- task command do
15
+ %w[start stop restart].each do |command|
16
+ desc "#{command} resque"
17
+ task command do
18
+ on roles(:resque) do
19
+ execute "/etc/init.d/resque #{command}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ namespace :supervisor do
25
+ task :setup do
17
26
  on roles(:resque) do
18
- execute "/etc/init.d/resque #{command}"
27
+ template "resque_supervisor.erb", "/tmp/resque"
28
+ sudo "mv /tmp/resque /etc/supervisor/conf.d/resque.conf"
29
+ sudo "supervisorctl reread"
30
+ sudo "supervisorctl update" # it will auto start the application
31
+ end
32
+ end
33
+
34
+ %w[start stop restart].each do |command|
35
+ desc "#{command} resque"
36
+ task command do
37
+ on roles(:resque) do
38
+ execute "supervisorctl #{command} resque"
39
+ end
19
40
  end
20
41
  end
21
42
  end
@@ -2,20 +2,41 @@ namespace :resque_scheduler do
2
2
  desc "Install resque scheduler"
3
3
 
4
4
  desc "Setup resque scheduler configuration for this application"
5
- task :setup do
6
- on roles(:resque) do
7
- template "resque_scheduler_init.erb", "/tmp/resque_scheduler"
8
- sudo "mv /tmp/resque_scheduler /etc/init.d/resque_scheduler"
9
- sudo "chmod +x /etc/init.d/resque_scheduler"
10
- sudo "update-rc.d resque_scheduler defaults"
5
+ namespace :sysvinit do
6
+ task :setup do
7
+ on roles(:resque) do
8
+ template "resque_scheduler_init.erb", "/tmp/resque_scheduler"
9
+ sudo "mv /tmp/resque_scheduler /etc/init.d/resque_scheduler"
10
+ sudo "chmod +x /etc/init.d/resque_scheduler"
11
+ sudo "update-rc.d resque_scheduler defaults"
12
+ end
11
13
  end
12
- end
13
14
 
14
- %w[start stop restart].each do |command|
15
- desc "#{command} resque_scheduler"
16
- task command do
15
+ %w[start stop restart].each do |command|
16
+ desc "#{command} resque_scheduler"
17
+ task command do
18
+ on roles(:resque) do
19
+ execute "/etc/init.d/resque_scheduler #{command}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ namespace :supervisor do
25
+ task :setup do
17
26
  on roles(:resque) do
18
- execute "/etc/init.d/resque_scheduler #{command}"
27
+ template "resque_scheduler_supervisor.erb", "/tmp/resque_scheduler"
28
+ sudo "mv /tmp/resque_scheduler /etc/supervisor/conf.d/resque_scheduler.conf"
29
+ sudo "supervisorctl reread"
30
+ sudo "supervisorctl update" # it will auto start the application
31
+ end
32
+ end
33
+
34
+ %w[start stop restart].each do |command|
35
+ desc "#{command} resque_scheduler"
36
+ task command do
37
+ on roles(:resque) do
38
+ execute "supervisorctl #{command} resque_scheduler"
39
+ end
19
40
  end
20
41
  end
21
42
  end
@@ -2,20 +2,74 @@ namespace :sidekiq do
2
2
  desc "Install sidekiq"
3
3
 
4
4
  desc "Setup sidekiq configuration for this application"
5
- task :setup do
6
- on roles(:sidekiq) do
7
- template "sidekiq_init.erb", "/tmp/sidekiq"
8
- sudo "mv /tmp/sidekiq /etc/init.d/sidekiq"
9
- sudo "chmod +x /etc/init.d/sidekiq"
10
- sudo "update-rc.d sidekiq defaults"
5
+ namespace :sysvinit do
6
+ task :setup do
7
+ on roles(:sidekiq) do
8
+ template "sidekiq_init.erb", "/tmp/sidekiq"
9
+ sudo "mv /tmp/sidekiq /etc/init.d/sidekiq"
10
+ sudo "chmod +x /etc/init.d/sidekiq"
11
+ sudo "update-rc.d sidekiq defaults"
12
+ end
13
+ end
14
+
15
+ %w[start stop restart].each do |command|
16
+ desc "#{command} sidekiq"
17
+ task command do
18
+ on roles(:sidekiq) do
19
+ execute "/etc/init.d/sidekiq #{command}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ namespace :supervisor do
25
+ task :setup do
26
+ on roles(:sidekiq) do
27
+ template "sidekiq_supervisor.erb", "/tmp/sidekiq"
28
+ sudo "mv /tmp/sidekiq /etc/supervisor/conf.d/sidekiq.conf"
29
+ sudo "supervisorctl reread"
30
+ sudo "supervisorctl update" # it will auto start the application
31
+ end
32
+ end
33
+
34
+ %w[start stop restart].each do |command|
35
+ desc "#{command} sidekiq"
36
+ task command do
37
+ on roles(:sidekiq) do
38
+ execute "supervisorctl #{command} sidekiq"
39
+ end
40
+ end
41
+ end
42
+ task :unload do
43
+ desc "tell sidekiq stop receive new jobs, called at the beginning"
44
+ on roles(:sidekiq) do
45
+ execute "supervisorctl signal TSTP sidekiq"
46
+ end
47
+ end
48
+ task :rolling_restart do
49
+ desc "used for rolling restart, only available on enterprise version"
50
+ on roles(:sidekiq) do
51
+ execute "supervisorctl signal USR2 sidekiq"
52
+ end
11
53
  end
12
- end
13
54
 
14
- %w[start stop restart].each do |command|
15
- desc "#{command} sidekiq"
16
- task command do
55
+ %w[start_group stop_group restart_group].each do |command|
56
+ desc "#{command} sidekiq"
57
+ task command do
58
+ on roles(:sidekiq) do
59
+ execute "supervisorctl #{command.split('_')[0]} sidekiq:*"
60
+ end
61
+ end
62
+ end
63
+ task :unload_group do
64
+ desc "tell sidekiq stop receive new jobs, called at the beginning"
65
+ on roles(:sidekiq) do
66
+ execute "supervisorctl signal TSTP sidekiq:*"
67
+ end
68
+ end
69
+ task :rolling_restart_group do
70
+ desc "used for rolling restart, only available on enterprise version"
17
71
  on roles(:sidekiq) do
18
- execute "/etc/init.d/sidekiq #{command}"
72
+ execute "supervisorctl signal USR2 sidekiq:*"
19
73
  end
20
74
  end
21
75
  end
@@ -0,0 +1,9 @@
1
+ namespace :supervisor do
2
+ desc "Setup supervisor configuration for this application"
3
+ task :setup do
4
+ on roles(:app) do
5
+ template "supervisor.erb", "/tmp/supervisor"
6
+ sudo "mv /tmp/supervisor /etc/supervisor/supervisord.conf"
7
+ end
8
+ end
9
+ end
@@ -1,23 +1,57 @@
1
1
  namespace :unicorn do
2
2
  desc "Install unicorn"
3
+ namespace :sysvinit do
4
+ task :setup do
5
+ on roles(:web) do
6
+ template "unicorn_init.erb", "/tmp/unicorn"
7
+ sudo "mv /tmp/unicorn /etc/init.d/#{fetch(:application)}"
8
+ sudo "chmod +x /etc/init.d/#{fetch(:application)}"
9
+ sudo "update-rc.d #{fetch(:application)} defaults"
10
+ template "nginx_config.erb", "/tmp/nginx_config"
11
+ sudo "mv /tmp/nginx_config /etc/nginx/sites-enabled/#{fetch(:application)}"
12
+ end
13
+ end
3
14
 
4
- desc "Setup unicorn configuration for this application"
5
- task :setup do
6
- on roles(:web) do
7
- template "unicorn_init.erb", "/tmp/unicorn"
8
- sudo "mv /tmp/unicorn /etc/init.d/#{fetch(:application)}"
9
- sudo "chmod +x /etc/init.d/#{fetch(:application)}"
10
- sudo "update-rc.d #{fetch(:application)} defaults"
11
- template "nginx_config.erb", "/tmp/nginx_config"
12
- sudo "mv /tmp/nginx_config /etc/nginx/sites-enabled/#{fetch(:application)}"
15
+ %w[start stop restart reload].each do |command|
16
+ desc "#{command} unicorn"
17
+ task command do
18
+ on roles(:web) do
19
+ execute "/etc/init.d/#{fetch(:application)} #{command}"
20
+ end
21
+ end
13
22
  end
14
23
  end
24
+ namespace :supervisor do
25
+ desc "Setup unicorn configuration for this application"
26
+ task :setup do
27
+ on roles(:web) do
28
+ template "unicorn_supervisor.erb", "/tmp/unicorn"
29
+ sudo "mv /tmp/unicorn /etc/supervisor/conf.d/#{fetch(:application)}.conf"
30
+ sudo "supervisorctl reread"
31
+ sudo "supervisorctl update" # it will auto start the application
32
+ template "nginx_config.erb", "/tmp/nginx_config"
33
+ sudo "mv /tmp/nginx_config /etc/nginx/sites-enabled/#{fetch(:application)}"
34
+ end
35
+ end
15
36
 
16
- %w[start stop restart].each do |command|
17
- desc "#{command} unicorn"
18
- task command do
37
+ task :start do
38
+ on roles(:web) do
39
+ execute "supervisorctl start #{fetch(:application)}"
40
+ end
41
+ end
42
+ task :stop do
43
+ on roles(:web) do
44
+ execute "supervisorctl signal QUIT #{fetch(:application)}"
45
+ end
46
+ end
47
+ task :restart do
48
+ on roles(:web) do
49
+ execute "supervisorctl signal USR2 #{fetch(:application)}"
50
+ end
51
+ end
52
+ task :reload do
19
53
  on roles(:web) do
20
- execute "/etc/init.d/#{fetch(:application)} #{command}"
54
+ execute "supervisorctl signal HUP #{fetch(:application)}"
21
55
  end
22
56
  end
23
57
  end
@@ -1,8 +1,10 @@
1
1
  <%= fetch(:deploy_to) %>/shared/log/*.log {
2
- daily
2
+ su deploy deploy
3
+ maxsize 1G
4
+ weekly
3
5
  missingok
4
6
  copytruncate
5
- rotate 7
7
+ rotate 5
6
8
  compress
7
9
  notifempty
8
- }
10
+ }
@@ -15,6 +15,9 @@ server {
15
15
  }
16
16
 
17
17
  location @<%= fetch(:application) %> {
18
+ proxy_set_header X-Forwarded-Proto $scheme;
19
+ proxy_set_header X-Forwarded-Ssl on;
20
+ proxy_set_header X-Forwarded-Port 443;
18
21
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
19
22
  proxy_set_header Host $http_host;
20
23
  proxy_redirect off;
@@ -26,4 +29,4 @@ server {
26
29
  error_page 500 502 503 504 /500.html;
27
30
  client_max_body_size 1G;
28
31
  keepalive_timeout 10;
29
- }
32
+ }
@@ -7,10 +7,8 @@ server {
7
7
  server_name <%= fetch(:server_address) %>;
8
8
 
9
9
  root <%= fetch(:deploy_to) %>/current/public;
10
- access_log <%= fetch(:deploy_to) %>/current/log/nginx.access.log;
11
- error_log <%= fetch(:deploy_to) %>/current/log/nginx.error.log info;
12
10
 
13
- location ^~ /assets/ {
11
+ location ^~ /packs/ {
14
12
  gzip_static on;
15
13
  expires max;
16
14
  add_header Cache-Control public;
@@ -18,6 +16,7 @@ server {
18
16
 
19
17
  try_files $uri $uri @<%= fetch(:application) %>;
20
18
  location @<%= fetch(:application) %> {
19
+ proxy_set_header X-Forwarded-Proto $scheme;
21
20
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
22
21
  proxy_set_header Host $http_host;
23
22
  proxy_redirect off;
@@ -37,4 +36,4 @@ server {
37
36
  error_page 500 502 503 504 /500.html;
38
37
  client_max_body_size 10M;
39
38
  keepalive_timeout 10;
40
- }
39
+ }
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env puma
2
+
3
+ directory '<%= current_path %>'
4
+ rackup '<%= current_path %>/config.ru'
5
+ environment '<%= fetch(:rails_env, 'production') %>'
6
+ tag '<%= fetch(:application)%>'
7
+ pidfile '<%= shared_path %>/pids/puma.pid'
8
+ state_path '<%= shared_path %>/pids/puma.state'
9
+ stdout_redirect '<%= shared_path %>/log/<%= fetch(:application)%>.log', '<%= shared_path %>/log/<%= fetch(:application)%>.log', true
10
+
11
+ threads <%= fetch(:puma_threads, [0, 1]).join(',')%>
12
+
13
+ bind 'unix:///tmp/<%= fetch(:application)%>.sock'
14
+
15
+ activate_control_app 'unix://<%= shared_path %>/tmp/sockets/pumactl.sock'
16
+
17
+ workers <%= fetch(:puma_workers, 2) %>
18
+
19
+ preload_app!
20
+
21
+ on_restart do
22
+ puts 'Refreshing Gemfile'
23
+ ENV['BUNDLE_GEMFILE'] = '<%= current_path %>/Gemfile'
24
+ end
25
+
26
+ before_fork do
27
+ ActiveRecord::Base.connection_pool.disconnect!
28
+ end
29
+
30
+ on_worker_boot do
31
+ ActiveSupport.on_load(:active_record) do
32
+ ActiveRecord::Base.establish_connection
33
+ end
34
+ end
@@ -13,7 +13,7 @@
13
13
  USER="<%= fetch(:user) %>"
14
14
  DAEMON=puma
15
15
  PROJECT_PATH="<%= fetch(:deploy_to) %>"
16
- DAEMON_OPTS="-e <%= fetch(:rails_env) %> -d"
16
+ DAEMON_OPTS="-C $PROJECT_PATH/shared/config/puma.rb -e <%= fetch(:rails_env) %> -d"
17
17
  NAME=puma
18
18
  DESC="puma app for $USER"
19
19
  PID="$PROJECT_PATH/shared/pids/puma.pid"
@@ -33,17 +33,17 @@ case "$1" in
33
33
  ;;
34
34
  stop)
35
35
  echo -n "Stopping $DESC: "
36
- kill -QUIT `cat $PID`
36
+ kill -INT `cat $PID`
37
37
  echo "$NAME."
38
38
  ;;
39
39
  restart)
40
40
  echo -n "Restarting $DESC: "
41
- kill -USR2 `cat $PID`
41
+ kill -USR1 `cat $PID`
42
42
  echo "$NAME."
43
43
  ;;
44
44
  reload)
45
45
  echo -n "Reloading $DESC configuration: "
46
- kill -HUP `cat $PID`
46
+ kill -USR2 `cat $PID`
47
47
  echo "$NAME."
48
48
  ;;
49
49
  *)
@@ -0,0 +1,13 @@
1
+ [program:<%= fetch(:application) %>]
2
+ user=<%= fetch(:user) %>
3
+ environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
4
+ directory=<%= fetch(:deploy_to) %>/current
5
+ command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec puma -C <%= fetch(:deploy_to) %>/shared/config/puma.rb -e <%= fetch(:rails_env) %>
6
+ autostart=<%= fetch(:autostart, 'true') %>
7
+ autorestart=<%= fetch(:autorestart, 'true') %>
8
+ startsecs=5
9
+ startretries=3
10
+ stderr_logfile=<%= fetch(:deploy_to) %>/shared/log/<%= fetch(:application) %>.log
11
+ stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/<%= fetch(:rails_env) %>.log
12
+ stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '5GB') %>
13
+ stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
@@ -10,7 +10,7 @@
10
10
  # Description: starts resque
11
11
  ### END INIT INFO
12
12
 
13
- USER="deploy"
13
+ USER="<%= fetch(:user) %>"
14
14
  PROJECT_PATH="<%= fetch(:deploy_to) %>"
15
15
  NAME=resque
16
16
  DESC="Resque app for $USER"
@@ -46,4 +46,4 @@ case "$1" in
46
46
  ;;
47
47
  esac
48
48
 
49
- exit 0
49
+ exit 0
@@ -10,7 +10,7 @@
10
10
  # Description: starts resque scheduler
11
11
  ### END INIT INFO
12
12
 
13
- USER="deploy"
13
+ USER="<%= fetch(:user) %>"
14
14
  PROJECT_PATH="<%= fetch(:deploy_to) %>"
15
15
  NAME="resque_scheduler"
16
16
  DESC="Resque Scheduler for $USER"
@@ -46,4 +46,4 @@ case "$1" in
46
46
  ;;
47
47
  esac
48
48
 
49
- exit 0
49
+ exit 0
@@ -0,0 +1,13 @@
1
+ [program:resque_scheduler]
2
+ user=<%= fetch(:user) %>
3
+ environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
4
+ directory=<%= fetch(:deploy_to) %>/current
5
+ command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE='*' environment resque:scheduler 2>&1 > <%= fetch(:deploy_to) %>/shared/log/resque_scheduler.log
6
+ autostart=<%= fetch(:autostart, 'true') %>
7
+ autorestart=<%= fetch(:autorestart, 'true') %>
8
+ stopsignal=QUIT
9
+ startsecs=5
10
+ startretries=3
11
+ stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/resque_scheduler.log
12
+ stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '1GB') %>
13
+ stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
@@ -0,0 +1,13 @@
1
+ [program:resque]
2
+ user=<%= fetch(:user) %>
3
+ environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
4
+ directory=<%= fetch(:deploy_to) %>/current
5
+ command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE=critical,default,mailers,low environment resque:work 2>&1 > <%= fetch(:deploy_to) %>/shared/log/resque.log
6
+ autostart=<%= fetch(:autostart, 'true') %>
7
+ autorestart=<%= fetch(:autorestart, 'true') %>
8
+ stopsignal=QUIT
9
+ startsecs=5
10
+ startretries=3
11
+ stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/resque.log
12
+ stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '1GB') %>
13
+ stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
@@ -10,7 +10,7 @@
10
10
  # Description: starts sidekiq
11
11
  ### END INIT INFO
12
12
 
13
- USER="deploy"
13
+ USER="<%= fetch(:user) %>"
14
14
  DAEMON=sidekiq
15
15
  PROJECT_PATH="<%= fetch(:deploy_to) %>"
16
16
  NAME=sidekiq
@@ -0,0 +1,12 @@
1
+ [program:sidekiq]
2
+ user=<%= fetch(:user) %>
3
+ environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
4
+ directory=<%= fetch(:deploy_to) %>/current
5
+ command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec sidekiq -L <%= fetch(:deploy_to) %>/shared/log/sidekiq.log -e <%= fetch(:rails_env) %>
6
+ autostart=<%= fetch(:autostart, 'true') %>
7
+ autorestart=<%= fetch(:autorestart, 'true') %>
8
+ startsecs=5
9
+ startretries=3
10
+ stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/sidekiq.log
11
+ stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '1GB') %>
12
+ stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
@@ -0,0 +1,19 @@
1
+ ; Generated with pixelforce recipies
2
+ [unix_http_server]
3
+ file=/tmp/supervisor.sock ; (the path to the socket file)
4
+ chmod=0700 ; sockef file mode (default 0700)
5
+
6
+ [supervisord]
7
+ user=<%= fetch(:user) %>
8
+ logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
9
+ pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
10
+
11
+ [rpcinterface:supervisor]
12
+ supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
13
+
14
+ [supervisorctl]
15
+ serverurl=unix:///tmp/supervisor.sock
16
+
17
+ [include]
18
+ files = /etc/supervisor/conf.d/*.conf
19
+
@@ -0,0 +1,13 @@
1
+ [program:<%= fetch(:application) %>]
2
+ user=<%= fetch(:user) %>
3
+ environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
4
+ directory=<%= fetch(:deploy_to) %>/current
5
+ command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec unicornherder -u unicorn -p <%= fetch(:deploy_to) %>/shared/pids/unicorn.pid -- -c config/unicorn.rb -E <%= fetch(:rails_env) %>
6
+ autostart=<%= fetch(:autostart, 'true') %>
7
+ autorestart=<%= fetch(:autorestart, 'true') %>
8
+ startsecs=5
9
+ startretries=3
10
+ stderr_logfile=<%= fetch(:deploy_to) %>/shared/log/<%= fetch(:application) %>.log
11
+ stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/<%= fetch(:rails_env) %>.log
12
+ stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '5GB') %>
13
+ stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
@@ -1,3 +1,3 @@
1
1
  module PixelforceRecipes
2
- VERSION = "1.6"
2
+ VERSION = "2.3"
3
3
  end
@@ -3,18 +3,8 @@ require "capistrano"
3
3
 
4
4
  if defined?(Capistrano::VERSION)
5
5
  if Capistrano::VERSION.to_s.split('.').first.to_i >= 3
6
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/base")
7
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/sidekiq")
8
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/resque")
9
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/logrotate")
10
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/unicorn")
11
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/puma")
6
+ Dir[File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/*.rb")].each {|file| require file }
12
7
  else
13
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/base")
14
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/unicorn")
15
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/sidekiq")
16
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/resque")
17
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/puma")
18
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/logrotate")
8
+ Dir[File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/*.rb")].each {|file| require file }
19
9
  end
20
- end
10
+ end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.12"
23
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rake", "~> 13.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
25
  spec.add_dependency(%q<capistrano>, ["> 2.0.0"])
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixelforce_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: '2.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Zhang
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-19 00:00:00.000000000 Z
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +89,7 @@ files:
89
89
  - lib/pixelforce_recipes/capistrano_3_recipes/resque.rb
90
90
  - lib/pixelforce_recipes/capistrano_3_recipes/resque_scheduler.rb
91
91
  - lib/pixelforce_recipes/capistrano_3_recipes/sidekiq.rb
92
+ - lib/pixelforce_recipes/capistrano_3_recipes/supervisor.rb
92
93
  - lib/pixelforce_recipes/capistrano_3_recipes/unicorn.rb
93
94
  - lib/pixelforce_recipes/legacy_recipes/base.rb
94
95
  - lib/pixelforce_recipes/legacy_recipes/logrotate.rb
@@ -100,18 +101,25 @@ files:
100
101
  - lib/pixelforce_recipes/templates/logrotate.erb
101
102
  - lib/pixelforce_recipes/templates/nginx_config.erb
102
103
  - lib/pixelforce_recipes/templates/nginx_puma_config.erb
104
+ - lib/pixelforce_recipes/templates/puma.rb.erb
103
105
  - lib/pixelforce_recipes/templates/puma_init.erb
106
+ - lib/pixelforce_recipes/templates/puma_supervisor.erb
104
107
  - lib/pixelforce_recipes/templates/resque_init.erb
105
108
  - lib/pixelforce_recipes/templates/resque_scheduler_init.erb
109
+ - lib/pixelforce_recipes/templates/resque_scheduler_supervisor.erb
110
+ - lib/pixelforce_recipes/templates/resque_supervisor.erb
106
111
  - lib/pixelforce_recipes/templates/sidekiq_init.erb
112
+ - lib/pixelforce_recipes/templates/sidekiq_supervisor.erb
113
+ - lib/pixelforce_recipes/templates/supervisor.erb
107
114
  - lib/pixelforce_recipes/templates/unicorn_init.erb
115
+ - lib/pixelforce_recipes/templates/unicorn_supervisor.erb
108
116
  - lib/pixelforce_recipes/version.rb
109
117
  - pixelforce_recipes.gemspec
110
118
  homepage: https://git.pixelforcesystems.com.au/
111
119
  licenses:
112
120
  - MIT
113
121
  metadata: {}
114
- post_install_message:
122
+ post_install_message:
115
123
  rdoc_options: []
116
124
  require_paths:
117
125
  - lib
@@ -126,9 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
134
  - !ruby/object:Gem::Version
127
135
  version: '0'
128
136
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.5.1
131
- signing_key:
137
+ rubygems_version: 3.0.6
138
+ signing_key:
132
139
  specification_version: 4
133
140
  summary: Write a short summary, because Rubygems requires one.
134
141
  test_files: []