pixelforce_recipes 2.4 → 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: 99cd84bf28bedffc49e0b17d0abadb17948931d83adfff7e4ea203085e846595
4
- data.tar.gz: 5f29ecc95d3af1e4745ece64f81ea1412616b77efbf3e8809e7eb516186cb490
3
+ metadata.gz: 56d761b88d6996453532e7b31d596541e7f53534b40df4d4b0cc9a3f075c9d1b
4
+ data.tar.gz: c6e5f42615c11b996da96e756eb38f856ad8c187612e2a4342c60838692090b4
5
5
  SHA512:
6
- metadata.gz: e77266c598a308a077dac8cf13e8965171a3eda2ca41f8e055863303093f1bf3e58a34de975e2d3f6d05265f490e3b7cc451f149781ba87fa86d7da0902c9b62
7
- data.tar.gz: 16bad33ad82245b2a4a9d33bea8eee1e2d1a2bc79337570656d34e0d90f2d2292b74699395a1c677b55cada6ce54dd43d59d0bfe8227d634d8f6e881ec1d329f
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 (2.4)
4
+ pixelforce_recipes (3.0)
5
5
  capistrano (> 2.0.0)
6
6
 
7
7
  GEM
@@ -1,66 +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"
8
7
  execute "mkdir -p #{shared_path}/pids"
9
8
  end
10
9
  end
11
10
 
12
- namespace :sysvinit do
11
+ namespace :systemd do
13
12
  task :setup do
14
13
  on roles(:web) do
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)}"
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'
21
19
  end
22
20
  end
23
21
 
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
22
+ task :restart do
23
+ on roles(:web) do
24
+ sudo 'systemctl reload puma'
30
25
  end
31
26
  end
32
27
  end
33
28
 
34
29
  namespace :supervisor do
35
- task :setup do
30
+ task :uninstall do
36
31
  on roles(:web) do
37
- template "puma_supervisor.erb", "/tmp/puma"
38
- sudo "mv /tmp/puma /etc/supervisor/conf.d/#{fetch(:application)}.conf"
32
+ sudo "rm /etc/supervisor/conf.d/#{fetch(:application)}.conf"
39
33
  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)}"
34
+ sudo "supervisorctl update"
64
35
  end
65
36
  end
66
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
@@ -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.4"
2
+ VERSION = "3.0"
3
3
  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.4'
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-09-13 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') %>