immosquare-capistrano 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare/capistrano/defaults.rb +3 -1
- data/lib/immosquare/capistrano/helpers.rb +5 -5
- data/lib/immosquare/capistrano/puma.rb +7 -0
- data/lib/immosquare/capistrano/sidekiq.rb +9 -0
- data/lib/immosquare/capistrano/tasks/puma.rake +101 -0
- data/lib/immosquare/capistrano/tasks/sidekiq.rake +81 -0
- data/lib/immosquare/capistrano/tasks/solid_queue.rake +9 -8
- data/lib/immosquare/capistrano/templates/puma.service.erb +26 -0
- data/lib/immosquare/capistrano/templates/sidekiq.service.erb +27 -0
- data/lib/immosquare/capistrano/templates/solid_queue.service.erb +4 -4
- data/lib/immosquare-capistrano/version.rb +1 -1
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82e36c7fd3cb858ab8867e48f72dabf834e2b422f33376a5da5603ac13e1dfab
|
4
|
+
data.tar.gz: 63c30e946a439d38d99d54b54769dc143c4907a2a6c05d5ba756131878fb8130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7755c79f7df98e5af1778f265f08d50b72ce9cb198fae3c4f52438e73a7c2f36b64782f6b165fdd00b4fc38b3c43aa237c83dcf76738668cd390a008429abd8
|
7
|
+
data.tar.gz: a92b7d0554675cd6cd4cc39eb992f1b026412fe7144b0b1e2b9375a1715c225f8f65ed29899e49b183281469fb3770b9e8b34529a4df656e168e252f47295464
|
@@ -1,5 +1,7 @@
|
|
1
1
|
namespace :load do
|
2
2
|
task :defaults do
|
3
|
-
set_if_empty :
|
3
|
+
set_if_empty :puma_service_unit_name, -> { "puma_#{fetch(:application)}_#{fetch(:stage)}" }
|
4
|
+
set_if_empty :sidekiq_service_unit_name, -> { "sidekiq_#{fetch(:application)}_#{fetch(:stage)}" }
|
5
|
+
set_if_empty :solid_queue_service_unit_name, -> { "solid_queue_#{fetch(:application)}_#{fetch(:stage)}" }
|
4
6
|
end
|
5
7
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Capistrano
|
2
|
-
module
|
2
|
+
module Immosquare
|
3
3
|
module Helpers
|
4
4
|
##============================================================##
|
5
5
|
## Get the path to bundle command
|
@@ -12,12 +12,12 @@ module Capistrano
|
|
12
12
|
"#{File.dirname(__FILE__)}/templates/#{service}.service.erb"
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.service_name
|
16
|
-
"#{fetch(:
|
15
|
+
def self.service_name(service)
|
16
|
+
"#{fetch(:"#{service}_service_unit_name")}.service"
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.result_path
|
20
|
-
"#{fetch(:tmp_dir)}/#{service_name}"
|
19
|
+
def self.result_path(service)
|
20
|
+
"#{fetch(:tmp_dir)}/#{service_name(service)}"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
|
2
|
+
namespace :puma do
|
3
|
+
##============================================================##
|
4
|
+
## Install puma service
|
5
|
+
##============================================================##
|
6
|
+
desc "Install puma service"
|
7
|
+
task :install do
|
8
|
+
on roles(:app) do
|
9
|
+
template_path = File.read(Capistrano::Immosquare::Helpers.template_path("puma"))
|
10
|
+
result = ERB.new(template_path).result(binding)
|
11
|
+
result_path = Capistrano::Immosquare::Helpers.result_path("puma")
|
12
|
+
service_name = Capistrano::Immosquare::Helpers.service_name("puma")
|
13
|
+
|
14
|
+
##============================================================##
|
15
|
+
## Upload the service file to the server
|
16
|
+
##============================================================##
|
17
|
+
upload!(StringIO.new(result), result_path)
|
18
|
+
|
19
|
+
##============================================================##
|
20
|
+
## Move the service file to the systemd directory
|
21
|
+
##============================================================##
|
22
|
+
sudo "mv #{result_path} /etc/systemd/system/#{service_name}"
|
23
|
+
|
24
|
+
##============================================================##
|
25
|
+
## Reload the systemd daemon and quiet the service
|
26
|
+
##============================================================##
|
27
|
+
sudo "systemctl daemon-reload"
|
28
|
+
sudo "systemctl enable #{service_name}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
##============================================================##
|
33
|
+
## Uninstall puma service
|
34
|
+
##============================================================##
|
35
|
+
desc "Uninstall puma service"
|
36
|
+
task :uninstall do
|
37
|
+
on roles(:app) do
|
38
|
+
service_name = Capistrano::Immosquare::Helpers.service_name("puma")
|
39
|
+
|
40
|
+
if test("systemctl list-units --full -all | grep -Fq '#{service_name}'")
|
41
|
+
sudo("systemctl stop #{service_name}")
|
42
|
+
sudo("systemctl disable #{service_name}")
|
43
|
+
sudo("rm -f /etc/systemd/system/#{service_name}")
|
44
|
+
sudo("systemctl daemon-reload")
|
45
|
+
else
|
46
|
+
info("Service #{service_name} does not exist and does not need to be disabled.")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
##============================================================##
|
53
|
+
## Start puma
|
54
|
+
##============================================================##
|
55
|
+
desc "Start puma"
|
56
|
+
task :start do
|
57
|
+
on roles(:app) do
|
58
|
+
sudo "systemctl start #{Capistrano::Immosquare::Helpers.service_name("puma")}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
##============================================================##
|
63
|
+
## Stop puma (force immediate termination)
|
64
|
+
##============================================================##
|
65
|
+
desc "Stop puma (force immediate termination)"
|
66
|
+
task :stop do
|
67
|
+
on roles(:app) do
|
68
|
+
sudo "systemctl stop #{Capistrano::Immosquare::Helpers.service_name("puma")}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
##============================================================##
|
73
|
+
## Restart puma
|
74
|
+
##============================================================##
|
75
|
+
desc "Restart puma"
|
76
|
+
task :restart do
|
77
|
+
on roles(:app) do
|
78
|
+
sudo "systemctl restart #{Capistrano::Immosquare::Helpers.service_name("puma")}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
##============================================================##
|
83
|
+
## Reload puma
|
84
|
+
##============================================================##
|
85
|
+
desc "Roload puma"
|
86
|
+
task :reload do
|
87
|
+
on roles(:app) do
|
88
|
+
service_ok = execute("systemctl status #{Capistrano::Immosquare::Helpers.service_name("puma")} > /dev/null", :raise_on_non_zero_exit => false)
|
89
|
+
sudo "systemctl #{service_ok ? "reload" : "restart"} #{Capistrano::Immosquare::Helpers.service_name("puma")}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
##============================================================##
|
95
|
+
## Smart restart puma (with phased restart if enabled)
|
96
|
+
##============================================================##
|
97
|
+
desc "Smart restart puma (with phased restart if enabled)"
|
98
|
+
task :smart_restart do
|
99
|
+
invoke fetch(:puma_phased_restart) ? "puma:reload" : "puma:restart"
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
|
2
|
+
namespace :sidekiq do
|
3
|
+
##============================================================##
|
4
|
+
## Install Sidekiq service
|
5
|
+
##============================================================##
|
6
|
+
desc "Install Sidekiq service"
|
7
|
+
task :install do
|
8
|
+
on roles(:app) do
|
9
|
+
template_path = File.read(Capistrano::Immosquare::Helpers.template_path("sidekiq"))
|
10
|
+
result = ERB.new(template_path).result(binding)
|
11
|
+
result_path = Capistrano::Immosquare::Helpers.result_path("sidekiq")
|
12
|
+
service_name = Capistrano::Immosquare::Helpers.service_name("sidekiq")
|
13
|
+
|
14
|
+
##============================================================##
|
15
|
+
## Upload the service file to the server
|
16
|
+
##============================================================##
|
17
|
+
upload!(StringIO.new(result), result_path)
|
18
|
+
|
19
|
+
##============================================================##
|
20
|
+
## Move the service file to the systemd directory
|
21
|
+
##============================================================##
|
22
|
+
sudo "mv #{result_path} /etc/systemd/system/#{service_name}"
|
23
|
+
|
24
|
+
##============================================================##
|
25
|
+
## Reload the systemd daemon and quiet the service
|
26
|
+
##============================================================##
|
27
|
+
sudo "systemctl daemon-reload"
|
28
|
+
sudo "systemctl enable #{service_name}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
##============================================================##
|
33
|
+
## Uninstall Sidekiq service
|
34
|
+
##============================================================##
|
35
|
+
desc "Uninstall Sidekiq service"
|
36
|
+
task :uninstall do
|
37
|
+
on roles(:app) do
|
38
|
+
service_name = Capistrano::Immosquare::Helpers.service_name("sidekiq")
|
39
|
+
|
40
|
+
if test("systemctl list-units --full -all | grep -Fq '#{service_name}'")
|
41
|
+
sudo("systemctl stop #{service_name}")
|
42
|
+
sudo("systemctl disable #{service_name}")
|
43
|
+
sudo("rm -f /etc/systemd/system/#{service_name}")
|
44
|
+
sudo("systemctl daemon-reload")
|
45
|
+
else
|
46
|
+
info("Service #{service_name} does not exist and does not need to be disabled.")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
##============================================================##
|
53
|
+
## Start sidekiq
|
54
|
+
##============================================================##
|
55
|
+
desc "Start sidekiq"
|
56
|
+
task :start do
|
57
|
+
on roles(:app) do
|
58
|
+
sudo "systemctl start #{Capistrano::Immosquare::Helpers.service_name("sidekiq")}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
##============================================================##
|
63
|
+
## Stop sidekiq (force immediate termination)
|
64
|
+
##============================================================##
|
65
|
+
desc "Stop sidekiq (force immediate termination)"
|
66
|
+
task :stop do
|
67
|
+
on roles(:app) do
|
68
|
+
sudo "systemctl stop #{Capistrano::Immosquare::Helpers.service_name("sidekiq")}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
##============================================================##
|
73
|
+
## Restart sidekiq
|
74
|
+
##============================================================##
|
75
|
+
desc "Restart sidekiq"
|
76
|
+
task :restart do
|
77
|
+
on roles(:app) do
|
78
|
+
sudo "systemctl restart #{Capistrano::Immosquare::Helpers.service_name("sidekiq")}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -6,9 +6,10 @@ namespace :solid_queue do
|
|
6
6
|
desc "Install SolidQueue service"
|
7
7
|
task :install do
|
8
8
|
on roles(:app) do
|
9
|
-
template_path = File.read(Capistrano::
|
9
|
+
template_path = File.read(Capistrano::Immosquare::Helpers.template_path("solid_queue"))
|
10
10
|
result = ERB.new(template_path).result(binding)
|
11
|
-
result_path = Capistrano::
|
11
|
+
result_path = Capistrano::Immosquare::Helpers.result_path("solid_queue")
|
12
|
+
service_name = Capistrano::Immosquare::Helpers.service_name("solid_queue")
|
12
13
|
|
13
14
|
##============================================================##
|
14
15
|
## Upload the service file to the server
|
@@ -18,13 +19,13 @@ namespace :solid_queue do
|
|
18
19
|
##============================================================##
|
19
20
|
## Move the service file to the systemd directory
|
20
21
|
##============================================================##
|
21
|
-
sudo "mv #{result_path} /etc/systemd/system/#{
|
22
|
+
sudo "mv #{result_path} /etc/systemd/system/#{service_name}"
|
22
23
|
|
23
24
|
##============================================================##
|
24
25
|
## Reload the systemd daemon and quiet the service
|
25
26
|
##============================================================##
|
26
27
|
sudo "systemctl daemon-reload"
|
27
|
-
sudo "systemctl enable #{
|
28
|
+
sudo "systemctl enable #{service_name}"
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -34,7 +35,7 @@ namespace :solid_queue do
|
|
34
35
|
desc "Uninstall SolidQueue service"
|
35
36
|
task :uninstall do
|
36
37
|
on roles(:app) do
|
37
|
-
service_name = Capistrano::
|
38
|
+
service_name = Capistrano::Immosquare::Helpers.service_name("solid_queue")
|
38
39
|
|
39
40
|
if test("systemctl list-units --full -all | grep -Fq '#{service_name}'")
|
40
41
|
sudo("systemctl stop #{service_name}")
|
@@ -54,7 +55,7 @@ namespace :solid_queue do
|
|
54
55
|
desc "Start solid_queue"
|
55
56
|
task :start do
|
56
57
|
on roles(:app) do
|
57
|
-
sudo "systemctl start #{Capistrano::
|
58
|
+
sudo "systemctl start #{Capistrano::Immosquare::Helpers.service_name("solid_queue")}"
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -64,7 +65,7 @@ namespace :solid_queue do
|
|
64
65
|
desc "Stop solid_queue (force immediate termination)"
|
65
66
|
task :stop do
|
66
67
|
on roles(:app) do
|
67
|
-
sudo "systemctl stop #{Capistrano::
|
68
|
+
sudo "systemctl stop #{Capistrano::Immosquare::Helpers.service_name("solid_queue")}"
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -74,7 +75,7 @@ namespace :solid_queue do
|
|
74
75
|
desc "Restart solid_queue"
|
75
76
|
task :restart do
|
76
77
|
on roles(:app) do
|
77
|
-
sudo "systemctl restart #{Capistrano::
|
78
|
+
sudo "systemctl restart #{Capistrano::Immosquare::Helpers.service_name("solid_queue")}"
|
78
79
|
end
|
79
80
|
end
|
80
81
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Puma Server for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
|
3
|
+
After=syslog.target network.target
|
4
|
+
|
5
|
+
|
6
|
+
[Service]
|
7
|
+
Type=notify
|
8
|
+
WatchdogSec=10
|
9
|
+
User=<%= fetch(:puma_user) %>
|
10
|
+
WorkingDirectory=<%= current_path %>
|
11
|
+
ExecStart=<%= Capistrano::Immosquare::Helpers.expanded_bundle_command %> exec puma -e production
|
12
|
+
ExecReload=/bin/kill -USR1 $MAINPID
|
13
|
+
|
14
|
+
|
15
|
+
RestartSec=1
|
16
|
+
Restart=on-failure
|
17
|
+
|
18
|
+
|
19
|
+
StandardOutput=append:<%= shared_path %>/log/puma_access.log
|
20
|
+
StandardError=append:<%= shared_path %>/log/puma_error.log
|
21
|
+
|
22
|
+
|
23
|
+
SyslogIdentifier=<%= fetch(:puma_service_unit_name) %>
|
24
|
+
|
25
|
+
[Install]
|
26
|
+
WantedBy=default.target
|
@@ -0,0 +1,27 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Sidekiq for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
|
3
|
+
After=syslog.target network.target
|
4
|
+
|
5
|
+
|
6
|
+
[Service]
|
7
|
+
Type=notify
|
8
|
+
WatchdogSec=10
|
9
|
+
User=<%= fetch(:sidekiq_user) %>
|
10
|
+
WorkingDirectory=<%= current_path %>
|
11
|
+
|
12
|
+
ExecStart=<%= Capistrano::Immosquare::Helpers.expanded_bundle_command %> exec sidekiq -e production
|
13
|
+
|
14
|
+
UMask=0002
|
15
|
+
|
16
|
+
RestartSec=1
|
17
|
+
Restart=on-failure
|
18
|
+
|
19
|
+
|
20
|
+
StandardOutput=append:<%= shared_path %>/log/sidekiq_access.log
|
21
|
+
StandardError=append:<%= shared_path %>/log/sidekiq_error.log
|
22
|
+
|
23
|
+
|
24
|
+
SyslogIdentifier=<%= fetch(:sidekiq_service_unit_name) %>
|
25
|
+
|
26
|
+
[Install]
|
27
|
+
WantedBy=default.target
|
@@ -8,13 +8,13 @@ Environment=RAILS_ENV=<%= fetch(:stage) %>
|
|
8
8
|
User=<%= fetch(:solid_queue_user) %>
|
9
9
|
WorkingDirectory=<%= current_path %>
|
10
10
|
|
11
|
-
ExecStart=<%= Capistrano::
|
11
|
+
ExecStart=<%= Capistrano::Immosquare::Helpers.expanded_bundle_command %> exec rake solid_queue:start
|
12
12
|
ExecReload=/bin/kill -HUP $MAINPID
|
13
13
|
ExecStop=/bin/kill -TERM $MAINPID
|
14
14
|
|
15
15
|
|
16
|
-
StandardOutput=append:<%= shared_path %>/log/
|
17
|
-
StandardError=append:<%= shared_path %>/log/
|
16
|
+
StandardOutput=append:<%= shared_path %>/log/solid_queue_access.log
|
17
|
+
StandardError=append:<%= shared_path %>/log/solid_queue_error.log
|
18
18
|
|
19
19
|
RestartSec=1
|
20
20
|
Restart=on-failure
|
@@ -22,4 +22,4 @@ Restart=on-failure
|
|
22
22
|
SyslogIdentifier=<%= fetch(:solid_queue_service_unit_name) %>
|
23
23
|
|
24
24
|
[Install]
|
25
|
-
WantedBy=
|
25
|
+
WantedBy=default.target
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immosquare-capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IMMO SQUARE
|
@@ -35,8 +35,14 @@ files:
|
|
35
35
|
- lib/immosquare-capistrano/version.rb
|
36
36
|
- lib/immosquare/capistrano/defaults.rb
|
37
37
|
- lib/immosquare/capistrano/helpers.rb
|
38
|
+
- lib/immosquare/capistrano/puma.rb
|
39
|
+
- lib/immosquare/capistrano/sidekiq.rb
|
38
40
|
- lib/immosquare/capistrano/solid_queue.rb
|
41
|
+
- lib/immosquare/capistrano/tasks/puma.rake
|
42
|
+
- lib/immosquare/capistrano/tasks/sidekiq.rake
|
39
43
|
- lib/immosquare/capistrano/tasks/solid_queue.rake
|
44
|
+
- lib/immosquare/capistrano/templates/puma.service.erb
|
45
|
+
- lib/immosquare/capistrano/templates/sidekiq.service.erb
|
40
46
|
- lib/immosquare/capistrano/templates/solid_queue.service.erb
|
41
47
|
homepage: https://github.com/IMMOSQUARE/immosquare-capistrano
|
42
48
|
licenses:
|