pixelforce_recipes 1.4 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile.lock +12 -12
  3. data/README.md +33 -1
  4. data/lib/pixelforce_recipes.rb +7 -13
  5. data/lib/pixelforce_recipes/capistrano_3_recipes/puma.rb +52 -11
  6. data/lib/pixelforce_recipes/capistrano_3_recipes/resque.rb +32 -11
  7. data/lib/pixelforce_recipes/capistrano_3_recipes/resque_scheduler.rb +43 -0
  8. data/lib/pixelforce_recipes/capistrano_3_recipes/sidekiq.rb +66 -12
  9. data/lib/pixelforce_recipes/capistrano_3_recipes/supervisor.rb +9 -0
  10. data/lib/pixelforce_recipes/capistrano_3_recipes/unicorn.rb +47 -13
  11. data/lib/pixelforce_recipes/legacy_recipes/base.rb +1 -1
  12. data/lib/pixelforce_recipes/legacy_recipes/resque_scheduler.rb +22 -0
  13. data/lib/pixelforce_recipes/templates/logrotate.erb +5 -3
  14. data/lib/pixelforce_recipes/templates/nginx_config.erb +4 -1
  15. data/lib/pixelforce_recipes/templates/nginx_puma_config.erb +2 -3
  16. data/lib/pixelforce_recipes/templates/puma.rb.erb +34 -0
  17. data/lib/pixelforce_recipes/templates/puma_init.erb +5 -5
  18. data/lib/pixelforce_recipes/templates/puma_supervisor.erb +13 -0
  19. data/lib/pixelforce_recipes/templates/resque_init.erb +2 -2
  20. data/lib/pixelforce_recipes/templates/resque_scheduler_init.erb +49 -0
  21. data/lib/pixelforce_recipes/templates/resque_scheduler_supervisor.erb +13 -0
  22. data/lib/pixelforce_recipes/templates/resque_supervisor.erb +13 -0
  23. data/lib/pixelforce_recipes/templates/sidekiq_init.erb +1 -1
  24. data/lib/pixelforce_recipes/templates/sidekiq_supervisor.erb +12 -0
  25. data/lib/pixelforce_recipes/templates/supervisor.erb +19 -0
  26. data/lib/pixelforce_recipes/templates/unicorn_supervisor.erb +13 -0
  27. data/lib/pixelforce_recipes/version.rb +1 -1
  28. data/pixelforce_recipes.gemspec +1 -1
  29. metadata +19 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4b5e21e690c3f0a6ef398cf285f22ff5e9c652d3
4
- data.tar.gz: c415d1d498cdbe3684460c73dd4298efe4785334
2
+ SHA256:
3
+ metadata.gz: 646a39fe331bfdfb9d399525d4727fbf3872eddaf7ef9da027928c64f2a8ccec
4
+ data.tar.gz: 12a83480e34c1da523d8aa82ce568f78e967bca86d633d64f352de589b08e920
5
5
  SHA512:
6
- metadata.gz: 68d3980743a9b71969e2ce5339eb8417e26bc3b9c30ab4ccda765c74cd1c5acfe9708032cbbf287215ad016c6abe4e719792592e30527ce92629e3aaba37736c
7
- data.tar.gz: e27fa4ca1a0ebc01467b18417351961f2e4dcd70c471e8321f4f23eb4571aa0a7dbe978b496e50c5e75f66cc408818cbc14b8a66eea455ad741e2dd83ce5896a
6
+ metadata.gz: e4b0912a870be8429c9c2811add7bc06e3854cd02bbec7fa3c973b3a1c312c02ba89d7c41c2febd12f3011e718f81b0809aee1ec367b6152ce7da2355741e755
7
+ data.tar.gz: 51d9cecf38a69ee98eeffe3a32403ff96c221f96601d28314aa9f030d7a36f95eb0fe64b49e48e8c310a11bcbb701d63a11666483155dcda83e3832b79e80cbe
data/Gemfile.lock CHANGED
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixelforce_recipes (1.4)
4
+ pixelforce_recipes (1.8)
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.12.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.3)
17
+ concurrent-ruby (1.1.6)
18
18
  diff-lcs (1.2.5)
19
- i18n (1.1.1)
19
+ i18n (1.8.2)
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 (2.0.0)
22
+ net-ssh (>= 2.6.5, < 6.0.0)
23
+ net-ssh (5.2.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.20.0)
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.16.6
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,16 +1,10 @@
1
1
  require "pixelforce_recipes/version"
2
2
  require "capistrano"
3
3
 
4
- if defined?(Capistrano::VERSION) && Capistrano::VERSION.to_s.split('.').first.to_i >= 3
5
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/base")
6
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/sidekiq")
7
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/resque")
8
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/logrotate")
9
- else
10
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/base")
11
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/unicorn")
12
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/sidekiq")
13
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/resque")
14
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/puma")
15
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/logrotate")
16
- end
4
+ if defined?(Capistrano::VERSION)
5
+ if Capistrano::VERSION.to_s.split('.').first.to_i >= 3
6
+ Dir[File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/*.rb")].each {|file| require file }
7
+ else
8
+ Dir[File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/*.rb")].each {|file| require file }
9
+ end
10
+ end
@@ -1,22 +1,63 @@
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"
12
8
  end
13
9
  end
10
+ namespace :sysvinit do
11
+ task :setup do
12
+ on roles(:web) do
13
+ template "puma_init.erb", "/tmp/puma"
14
+ sudo "mv /tmp/puma /etc/init.d/#{fetch(:application)}"
15
+ sudo "chmod +x /etc/init.d/#{fetch(:application)}"
16
+ sudo "update-rc.d #{fetch(:application)} defaults"
17
+ template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
18
+ sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
19
+ end
20
+ end
21
+
22
+ %w[start stop restart reload].each do |command|
23
+ desc "#{command} puma"
24
+ task command do
25
+ on roles(:web) do
26
+ execute "/etc/init.d/#{fetch(:application)} #{command}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ namespace :supervisor do
32
+ task :setup do
33
+ on roles(:web) do
34
+ template "puma_supervisor.erb", "/tmp/puma"
35
+ sudo "mv /tmp/puma /etc/supervisor/conf.d/#{fetch(:application)}.conf"
36
+ sudo "supervisorctl reread"
37
+ sudo "supervisorctl update" # it will auto start the application
38
+ template "nginx_puma_config.erb", "/tmp/nginx_puma_config"
39
+ sudo "mv /tmp/nginx_puma_config /etc/nginx/sites-enabled/#{fetch(:application)}"
40
+ end
41
+ end
14
42
 
15
- %w[start stop restart].each do |command|
16
- desc "#{command} puma"
17
- task command do
43
+ task :start do
44
+ on roles(:web) do
45
+ execute "supervisorctl start #{fetch(:application)}"
46
+ end
47
+ end
48
+ task :stop do
49
+ on roles(:web) do
50
+ execute "supervisorctl signal INT #{fetch(:application)}"
51
+ end
52
+ end
53
+ task :restart do
54
+ on roles(:web) do
55
+ execute "supervisorctl signal USR1 #{fetch(:application)}"
56
+ end
57
+ end
58
+ task :reload do
18
59
  on roles(:web) do
19
- execute "/etc/init.d/#{fetch(:application)} #{command}"
60
+ execute "supervisorctl signal USR2 #{fetch(:application)}"
20
61
  end
21
62
  end
22
63
  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
@@ -0,0 +1,43 @@
1
+ namespace :resque_scheduler do
2
+ desc "Install resque scheduler"
3
+
4
+ desc "Setup resque scheduler configuration for this application"
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
13
+ end
14
+
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
26
+ on roles(:resque) do
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
40
+ end
41
+ end
42
+ end
43
+ 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
11
13
  end
12
- end
13
14
 
14
- %w[start stop restart].each do |command|
15
- desc "#{command} sidekiq"
16
- task command do
17
- on roles(:resque) do
18
- execute "/etc/init.d/sidekiq #{command}"
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
53
+ end
54
+
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"
71
+ on roles(:sidekiq) do
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
@@ -3,7 +3,7 @@ if Capistrano::Configuration.instance(false)
3
3
  Capistrano::Configuration.instance(true).load do |instance|
4
4
 
5
5
  def template(from, to)
6
- erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
6
+ erb = File.read(File.expand_path("../../templates/#{from}", __FILE__))
7
7
  put ERB.new(erb).result(binding), to
8
8
  end
9
9
 
@@ -0,0 +1,22 @@
1
+ if Capistrano::Configuration.instance(false)
2
+ Capistrano::Configuration.instance(true).load do |instance|
3
+ namespace :resque_scheduler do
4
+ desc "Install resque scheduler"
5
+
6
+ desc "Setup resque scheduler configuration for this application"
7
+ task :setup, roles: :resque do
8
+ template "resque_scheduler_init.erb", "/tmp/resque_scheduler"
9
+ run "#{sudo} mv /tmp/resque_scheduler /etc/init.d/resque_scheduler"
10
+ run "#{sudo} chmod +x /etc/init.d/resque_scheduler"
11
+ run "#{sudo} update-rc.d resque_scheduler defaults"
12
+ end
13
+
14
+ %w[start stop restart].each do |command|
15
+ desc "#{command} resque scheduler"
16
+ task command do
17
+ run "/etc/init.d/resque_scheduler #{command}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ 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,8 +7,6 @@ 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
11
  location ^~ /assets/ {
14
12
  gzip_static on;
@@ -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) %>"
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
  *)
@@ -52,4 +52,4 @@ case "$1" in
52
52
  ;;
53
53
  esac
54
54
 
55
- exit 0
55
+ exit 0
@@ -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
@@ -0,0 +1,49 @@
1
+ #!/bin/bash
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: resque scheduler
5
+ # Required-Start: $local_fs $remote_fs $network $syslog
6
+ # Required-Stop: $local_fs $remote_fs $network $syslog
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: resque scheduler worker via init.d
10
+ # Description: starts resque scheduler
11
+ ### END INIT INFO
12
+
13
+ USER="<%= fetch(:user) %>"
14
+ PROJECT_PATH="<%= fetch(:deploy_to) %>"
15
+ NAME="resque_scheduler"
16
+ DESC="Resque Scheduler for $USER"
17
+ PID="$PROJECT_PATH/shared/pids/resque_scheduler.pid"
18
+ LOGFILE="$PROJECT_PATH/shared/log/resque.log"
19
+ CD_TO_APP_DIR="cd $PROJECT_PATH/current"
20
+
21
+
22
+ case "$1" in
23
+ start)
24
+ START_DAEMON_PROCESS="bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE='*' PIDFILE=$PID BACKGROUND=yes environment resque:scheduler 2>&1 > $LOGFILE"
25
+ echo -n "Starting $DESC: "
26
+ if [ `whoami` = 'root' ]; then
27
+ su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
28
+ else
29
+ /bin/bash -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
30
+ fi
31
+ echo "$NAME."
32
+ ;;
33
+ stop)
34
+ STOP_DAEMON_PROCESS="test -f $PID && kill -s QUIT `cat $PID` && rm -f $PID"
35
+ echo -n "Stopping $DESC: "
36
+ if [ `whoami` = 'root' ]; then
37
+ su - $USER -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
38
+ else
39
+ /bin/bash -l -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
40
+ fi
41
+ echo "$NAME."
42
+ ;;
43
+ *)
44
+ echo "Usage: $NAME {start|stop|restart|reload}" >&2
45
+ exit 1
46
+ ;;
47
+ esac
48
+
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.4"
2
+ VERSION = "2.1"
3
3
  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.4'
4
+ version: '2.1'
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: 2018-12-14 00:00:00.000000000 Z
11
+ date: 2021-06-29 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
@@ -87,28 +87,39 @@ files:
87
87
  - lib/pixelforce_recipes/capistrano_3_recipes/logrotate.rb
88
88
  - lib/pixelforce_recipes/capistrano_3_recipes/puma.rb
89
89
  - lib/pixelforce_recipes/capistrano_3_recipes/resque.rb
90
+ - lib/pixelforce_recipes/capistrano_3_recipes/resque_scheduler.rb
90
91
  - lib/pixelforce_recipes/capistrano_3_recipes/sidekiq.rb
92
+ - lib/pixelforce_recipes/capistrano_3_recipes/supervisor.rb
91
93
  - lib/pixelforce_recipes/capistrano_3_recipes/unicorn.rb
92
94
  - lib/pixelforce_recipes/legacy_recipes/base.rb
93
95
  - lib/pixelforce_recipes/legacy_recipes/logrotate.rb
94
96
  - lib/pixelforce_recipes/legacy_recipes/puma.rb
95
97
  - lib/pixelforce_recipes/legacy_recipes/resque.rb
98
+ - lib/pixelforce_recipes/legacy_recipes/resque_scheduler.rb
96
99
  - lib/pixelforce_recipes/legacy_recipes/sidekiq.rb
97
100
  - lib/pixelforce_recipes/legacy_recipes/unicorn.rb
98
101
  - lib/pixelforce_recipes/templates/logrotate.erb
99
102
  - lib/pixelforce_recipes/templates/nginx_config.erb
100
103
  - lib/pixelforce_recipes/templates/nginx_puma_config.erb
104
+ - lib/pixelforce_recipes/templates/puma.rb.erb
101
105
  - lib/pixelforce_recipes/templates/puma_init.erb
106
+ - lib/pixelforce_recipes/templates/puma_supervisor.erb
102
107
  - lib/pixelforce_recipes/templates/resque_init.erb
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
103
111
  - lib/pixelforce_recipes/templates/sidekiq_init.erb
112
+ - lib/pixelforce_recipes/templates/sidekiq_supervisor.erb
113
+ - lib/pixelforce_recipes/templates/supervisor.erb
104
114
  - lib/pixelforce_recipes/templates/unicorn_init.erb
115
+ - lib/pixelforce_recipes/templates/unicorn_supervisor.erb
105
116
  - lib/pixelforce_recipes/version.rb
106
117
  - pixelforce_recipes.gemspec
107
118
  homepage: https://git.pixelforcesystems.com.au/
108
119
  licenses:
109
120
  - MIT
110
121
  metadata: {}
111
- post_install_message:
122
+ post_install_message:
112
123
  rdoc_options: []
113
124
  require_paths:
114
125
  - lib
@@ -123,9 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
134
  - !ruby/object:Gem::Version
124
135
  version: '0'
125
136
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.5.1
128
- signing_key:
137
+ rubygems_version: 3.0.6
138
+ signing_key:
129
139
  specification_version: 4
130
140
  summary: Write a short summary, because Rubygems requires one.
131
141
  test_files: []