pixelforce_recipes 2.0 → 3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cc8944ed978b04a14ad148a608429564b240baf6c4aa0645e07c61879779b0f
4
- data.tar.gz: 8470f58a2d5e1b4688ffecbeef0b6214bf910ba2c8bb8728ffd204b316e98437
3
+ metadata.gz: 56d761b88d6996453532e7b31d596541e7f53534b40df4d4b0cc9a3f075c9d1b
4
+ data.tar.gz: c6e5f42615c11b996da96e756eb38f856ad8c187612e2a4342c60838692090b4
5
5
  SHA512:
6
- metadata.gz: bd84db64c8238e86f2d7715eb8c15f7123ca385436434b6ad2ca69c465ad29b164f4f8aa9f31bea2bbf05f432ee2b4e9c6bce8347fb5b36accb8d319babd6684
7
- data.tar.gz: 181f1e7f3b8a0b5e7fb2ac10921e5132f56218a1663354e89c3cbbb327dd3c5ca155ea6a6c6450797bd48de560df312ccb32aaa49eba14e65c3bad2c8ad9298f
6
+ metadata.gz: 5f865dbea5c22b406f3b5743c849f4d2a7ac978a4562cda20e32d919e921baba492f65677cc19dc5b2698e7fc823275e8acd4ffdbaa56a1feab4067afe2f6f71
7
+ data.tar.gz: 0d601bbb122787ab19458dfee70738c0daecd97c7f26c4e42a6627ec9a0d389ed58f72a874d6ecd1ded62c7e8a168a1051e4715e3ee8d44cb85feaf181c74123
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pixelforce_recipes (1.8)
4
+ pixelforce_recipes (3.0)
5
5
  capistrano (> 2.0.0)
6
6
 
7
7
  GEM
@@ -9,18 +9,18 @@ GEM
9
9
  specs:
10
10
  airbrussh (1.4.0)
11
11
  sshkit (>= 1.6.1, != 1.7.0)
12
- capistrano (3.12.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.6)
17
+ concurrent-ruby (1.1.9)
18
18
  diff-lcs (1.2.5)
19
- i18n (1.8.2)
19
+ i18n (1.8.10)
20
20
  concurrent-ruby (~> 1.0)
21
- net-scp (2.0.0)
22
- net-ssh (>= 2.6.5, < 6.0.0)
23
- net-ssh (5.2.0)
21
+ net-scp (3.0.0)
22
+ net-ssh (>= 2.6.5, < 7.0.0)
23
+ net-ssh (6.1.0)
24
24
  rake (13.0.1)
25
25
  rspec (3.5.0)
26
26
  rspec-core (~> 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.20.0)
38
+ sshkit (1.21.2)
39
39
  net-scp (>= 1.1.2)
40
40
  net-ssh (>= 2.8.0)
41
41
 
@@ -49,4 +49,4 @@ DEPENDENCIES
49
49
  rspec (~> 3.0)
50
50
 
51
51
  BUNDLED WITH
52
- 1.16.6
52
+ 1.17.3
@@ -1,63 +1,37 @@
1
1
  namespace :puma do
2
-
3
- desc "Setup puma configuration for this application"
2
+ desc 'Setup puma configuration for this application'
4
3
  task :config do
5
4
  on roles(:web) do
6
- template "puma.rb.erb", "/tmp/puma_conf"
5
+ template 'puma.rb.erb', '/tmp/puma_conf'
7
6
  sudo "mv /tmp/puma_conf #{shared_path}/config/puma.rb"
7
+ execute "mkdir -p #{shared_path}/pids"
8
8
  end
9
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
10
 
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
11
+ namespace :systemd do
32
12
  task :setup do
33
13
  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)}"
14
+ template 'puma_systemd.erb', '/tmp/puma.service'
15
+ sudo 'mv /tmp/puma.service /etc/systemd/system/puma.service'
16
+ sudo 'systemctl daemon-reload'
17
+ sudo 'systemctl enable puma.service'
18
+ sudo 'systemctl start puma.service'
40
19
  end
41
20
  end
42
21
 
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
22
  task :restart do
54
23
  on roles(:web) do
55
- execute "supervisorctl signal USR1 #{fetch(:application)}"
24
+ sudo 'systemctl reload puma'
56
25
  end
57
26
  end
58
- task :reload do
27
+ end
28
+
29
+ namespace :supervisor do
30
+ task :uninstall do
59
31
  on roles(:web) do
60
- execute "supervisorctl signal USR2 #{fetch(:application)}"
32
+ sudo "rm /etc/supervisor/conf.d/#{fetch(:application)}.conf"
33
+ sudo "supervisorctl reread"
34
+ sudo "supervisorctl update"
61
35
  end
62
36
  end
63
37
  end
@@ -1,75 +1,36 @@
1
1
  namespace :sidekiq do
2
- desc "Install sidekiq"
2
+ desc 'Install sidekiq'
3
3
 
4
- desc "Setup sidekiq configuration for this application"
5
- namespace :sysvinit do
4
+ namespace :systemd do
6
5
  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
6
+ on roles(:web) do
7
+ template 'sidekiq_systemd.erb', '/tmp/sidekiq.service'
8
+ sudo 'mv /tmp/sidekiq.service /etc/systemd/system/sidekiq.service'
9
+ sudo 'systemctl daemon-reload'
10
+ sudo 'systemctl enable sidekiq'
11
+ sudo 'systemctl start sidekiq'
31
12
  end
32
13
  end
33
14
 
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
15
  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"
16
+ on roles(:web) do
17
+ sudo 'systemctl kill -s TSTP sidekiq'
52
18
  end
53
19
  end
54
20
 
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:*"
21
+ task :restart do
22
+ on roles(:web) do
23
+ sudo 'systemctl restart sidekiq'
67
24
  end
68
25
  end
69
- task :rolling_restart_group do
70
- desc "used for rolling restart, only available on enterprise version"
26
+ end
27
+
28
+ namespace :supervisor do
29
+ task :uninstall do
71
30
  on roles(:sidekiq) do
72
- execute "supervisorctl signal USR2 sidekiq:*"
31
+ sudo 'rm/etc/supervisor/conf.d/sidekiq.conf'
32
+ sudo 'supervisorctl reread'
33
+ sudo 'supervisorctl update'
73
34
  end
74
35
  end
75
36
  end
@@ -8,7 +8,7 @@ server {
8
8
 
9
9
  root <%= fetch(:deploy_to) %>/current/public;
10
10
 
11
- location ^~ /assets/ {
11
+ location ^~ /packs/ {
12
12
  gzip_static on;
13
13
  expires max;
14
14
  add_header Cache-Control public;
@@ -16,12 +16,16 @@ server {
16
16
 
17
17
  try_files $uri $uri @<%= fetch(:application) %>;
18
18
  location @<%= fetch(:application) %> {
19
- proxy_set_header X-Forwarded-Proto $scheme;
19
+ proxy_set_header X-Forwarded-Proto https;
20
+ proxy_set_header X-Url-Scheme https;
21
+ proxy_set_header X-Forwarded-Ssl on;
22
+ proxy_set_header Front-End-Https on;
23
+
20
24
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21
25
  proxy_set_header Host $http_host;
22
- proxy_redirect off;
23
- proxy_buffering on;
24
- proxy_set_header X-Real-IP $remote_addr;
26
+ proxy_redirect off;
27
+ proxy_buffering on;
28
+ proxy_set_header X-Real-IP $remote_addr;
25
29
 
26
30
  proxy_pass http://<%= fetch(:application) %>;
27
31
  }
@@ -0,0 +1,19 @@
1
+ [Unit]
2
+ Description=Puma HTTP Server
3
+ After=network.target
4
+
5
+ [Service]
6
+ Type=simple
7
+ User=<%= fetch(:user) %>
8
+ WorkingDirectory=<%= fetch(:deploy_to) %>/current
9
+
10
+ # Helpful for debugging socket activation, etc.
11
+ # Environment=PUMA_DEBUG=1
12
+
13
+ ExecStart=/bin/bash -l -c 'bundle exec puma -C <%= fetch(:deploy_to) %>/shared/config/puma.rb -e <%= fetch(:rails_env) %>'
14
+ ExecStop=/bin/bash -l -c 'bundle exec pumactl -F <%= fetch(:deploy_to) %>/shared/config/puma.rb stop'
15
+ ExecReload=/bin/bash -l -c 'bundle exec pumactl -F <%= fetch(:deploy_to) %>/shared/config/puma.rb phased-restart'
16
+ Restart=always
17
+
18
+ [Install]
19
+ WantedBy=multi-user.target
@@ -0,0 +1,17 @@
1
+ [Unit]
2
+ Description=Sidekiq Background Process
3
+ After=syslog.target network.target
4
+
5
+ [Service]
6
+ Type=simple
7
+ User=<%= fetch(:user) %>
8
+ WorkingDirectory=<%= fetch(:deploy_to) %>/current
9
+
10
+ # Helpful for debugging socket activation, etc.
11
+ Environment=MALLOC_ARENA_MAX=2
12
+
13
+ ExecStart=/bin/bash -l -c 'bundle exec sidekiq -L <%= fetch(:deploy_to) %>/shared/log/sidekiq.log -e <%= fetch(:rails_env) %>'
14
+ Restart=always
15
+
16
+ [Install]
17
+ WantedBy=multi-user.target
@@ -1,3 +1,3 @@
1
1
  module PixelforceRecipes
2
- VERSION = "2.0"
2
+ VERSION = "3.0"
3
3
  end
@@ -3,19 +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/resque_scheduler")
10
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/supervisor")
11
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/capistrano_3_recipes/unicorn")
12
- 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 }
13
7
  else
14
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/base")
15
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/unicorn")
16
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/sidekiq")
17
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/resque")
18
- require File.expand_path("#{File.dirname(__FILE__)}/pixelforce_recipes/legacy_recipes/puma")
19
- 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 }
20
9
  end
21
10
  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: '2.0'
4
+ version: '3.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Zhang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-26 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,14 +102,14 @@ files:
102
102
  - lib/pixelforce_recipes/templates/nginx_config.erb
103
103
  - lib/pixelforce_recipes/templates/nginx_puma_config.erb
104
104
  - lib/pixelforce_recipes/templates/puma.rb.erb
105
- - lib/pixelforce_recipes/templates/puma_init.erb
106
- - lib/pixelforce_recipes/templates/puma_supervisor.erb
105
+ - lib/pixelforce_recipes/templates/puma_systemd.erb
107
106
  - lib/pixelforce_recipes/templates/resque_init.erb
108
107
  - lib/pixelforce_recipes/templates/resque_scheduler_init.erb
109
108
  - lib/pixelforce_recipes/templates/resque_scheduler_supervisor.erb
110
109
  - lib/pixelforce_recipes/templates/resque_supervisor.erb
111
110
  - lib/pixelforce_recipes/templates/sidekiq_init.erb
112
111
  - lib/pixelforce_recipes/templates/sidekiq_supervisor.erb
112
+ - lib/pixelforce_recipes/templates/sidekiq_systemd.erb
113
113
  - lib/pixelforce_recipes/templates/supervisor.erb
114
114
  - lib/pixelforce_recipes/templates/unicorn_init.erb
115
115
  - lib/pixelforce_recipes/templates/unicorn_supervisor.erb
@@ -1,55 +0,0 @@
1
- #!/bin/bash
2
-
3
- ### BEGIN INIT INFO
4
- # Provides: <%= fetch(:application) %>
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: starts the puma web server
10
- # Description: starts puma
11
- ### END INIT INFO
12
-
13
- USER="<%= fetch(:user) %>"
14
- DAEMON=puma
15
- PROJECT_PATH="<%= fetch(:deploy_to) %>"
16
- DAEMON_OPTS="-C $PROJECT_PATH/shared/config/puma.rb -e <%= fetch(:rails_env) %> -d"
17
- NAME=puma
18
- DESC="puma app for $USER"
19
- PID="$PROJECT_PATH/shared/pids/puma.pid"
20
-
21
- case "$1" in
22
- start)
23
- CD_TO_APP_DIR="cd $PROJECT_PATH/current"
24
- START_DAEMON_PROCESS="bundle exec $DAEMON $DAEMON_OPTS"
25
-
26
- echo -n "Starting $DESC: "
27
- if [ `whoami` = 'root' ]; then
28
- su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
29
- else
30
- $CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS
31
- fi
32
- echo "$NAME."
33
- ;;
34
- stop)
35
- echo -n "Stopping $DESC: "
36
- kill -INT `cat $PID`
37
- echo "$NAME."
38
- ;;
39
- restart)
40
- echo -n "Restarting $DESC: "
41
- kill -USR1 `cat $PID`
42
- echo "$NAME."
43
- ;;
44
- reload)
45
- echo -n "Reloading $DESC configuration: "
46
- kill -USR2 `cat $PID`
47
- echo "$NAME."
48
- ;;
49
- *)
50
- echo "Usage: $NAME {start|stop|restart|reload}" >&2
51
- exit 1
52
- ;;
53
- esac
54
-
55
- exit 0
@@ -1,13 +0,0 @@
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') %>