capistrano-systemd-multiservice 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +265 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/capistrano-systemd-multiservice.gemspec +29 -0
- data/lib/capistrano/systemd/multiservice.rb +112 -0
- data/lib/capistrano/systemd/multiservice/version.rb +15 -0
- data/lib/capistrano/tasks/systemd/multiservice.rake +28 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 591db5664fb74cd3907eb8052f2c47dd38862e61
|
4
|
+
data.tar.gz: a60a6fac2cc72fc6bcd75a144748140de4dc4684
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b4e0017a66b0cd651fdbb77f0ca95db322ba8797c0295b63d78ad33e5972be3aa68b2dab0a003df09ef1b21db57ee6243f6ae360bf08cdba0b6ce864c081544
|
7
|
+
data.tar.gz: 8bd2f3c38372ed90d71ec23dd29e4ddf27b3b374e763d54e6e159217d73f39465230fde509312a5b80d89b0387c716bffe4cf21b55641270aef0618e22b663a6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 YAMADA Tsuyoshi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,265 @@
|
|
1
|
+
# capistrano-systemd-multiservice
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/capistrano-systemd-multiservice.png)](https://rubygems.org/gems/capistrano-system) [![Build Status](https://secure.travis-ci.org/groovenauts/capistrano-systemd-multiservice.png)](https://travis-ci.org/groovenauts/capistrano-systemd-multiservice)
|
4
|
+
|
5
|
+
This gem adds capistrano tasks to control multiple services with systemd.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'capistrano-systemd-multiservice', require: false
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install capistrano-systemd-multiservice
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Add these lines to your Capfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require "capistrano/systemd/multiservice"
|
29
|
+
install_plugin Capistrano::Systemd::MultiService.new("example1")
|
30
|
+
install_plugin Capistrano::Systemd::MultiService.new("example2")
|
31
|
+
```
|
32
|
+
|
33
|
+
And put `config/systemd/example1.service.erb` (and `config/systemd/example2.service.erb`, ...) like this
|
34
|
+
(see [systemd.service(5)](https://www.freedesktop.org/software/systemd/man/systemd.service.html) for details) :
|
35
|
+
|
36
|
+
```
|
37
|
+
[Unit]
|
38
|
+
Description = <%= fetch(:application) %> application server example1
|
39
|
+
|
40
|
+
[Service]
|
41
|
+
Environment = RAILS_ENV=<%= fetch(:rails_env) %>
|
42
|
+
Environment = PWD=<%= current_path %>
|
43
|
+
WorkingDirectory = <%= current_path %>
|
44
|
+
ExecStart = bundle exec some-application-server start
|
45
|
+
User = exampleuser
|
46
|
+
Group = examplegroup
|
47
|
+
|
48
|
+
[Install]
|
49
|
+
WantedBy = multi-user.target
|
50
|
+
```
|
51
|
+
|
52
|
+
And add these lines to config/deploy.rb if you want to reload/restart services on deploy:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
after 'deploy:publishing', 'systemd:example1:restart'
|
56
|
+
after 'deploy:publishing', 'systemd:example2:reload-or-restart'
|
57
|
+
```
|
58
|
+
|
59
|
+
And then deploy.
|
60
|
+
|
61
|
+
```shell
|
62
|
+
# Upload and install systemd service unit files before deploy
|
63
|
+
cap STAGE systemd:example1:setup systemd:example2:setup
|
64
|
+
|
65
|
+
# Deploy as usual
|
66
|
+
cap STAGE deploy
|
67
|
+
```
|
68
|
+
|
69
|
+
## Capistrano Tasks
|
70
|
+
|
71
|
+
With `install_plugin Capistrano::Systemd::MultiService.new("example1")`,
|
72
|
+
following tasks are defined.
|
73
|
+
|
74
|
+
- `systemd:example1:setup`
|
75
|
+
- `systemd:example1:remove`
|
76
|
+
- `systemd:example1:validate`
|
77
|
+
- `systemd:example1:daemon-reload`
|
78
|
+
- `systemd:example1:start`
|
79
|
+
- `systemd:example1:stop`
|
80
|
+
- `systemd:example1:reload`
|
81
|
+
- `systemd:example1:restart`
|
82
|
+
- `systemd:example1:reload-or-restart`
|
83
|
+
- `systemd:example1:enable`
|
84
|
+
- `systemd:example1:disable`
|
85
|
+
|
86
|
+
See lib/capistrano/tasks/systemd/multiservice.rake, lib/capistrano/systemd/multiservice.rb for details.
|
87
|
+
|
88
|
+
## Configuration Variables
|
89
|
+
|
90
|
+
With `install_plugin Capistrano::Systemd::MultiService.new("example1")`,
|
91
|
+
following Configuration variables are defined.
|
92
|
+
|
93
|
+
- `:systemd_example1_role`
|
94
|
+
- `:systemd_example1_units_src`
|
95
|
+
- `:systemd_example1_units_dir`
|
96
|
+
- `:systemd_example1_units_dest`
|
97
|
+
- `:systemd_example1_instances`
|
98
|
+
- `:systemd_example1_service`
|
99
|
+
- `:systemd_example1_instance_services`
|
100
|
+
|
101
|
+
See lib/capistrano/systemd/multiservice.rb for details.
|
102
|
+
|
103
|
+
## Examples
|
104
|
+
|
105
|
+
### Rails application with unicorn and delayed\_job
|
106
|
+
|
107
|
+
#### `Capfile`
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
## ...snip...
|
111
|
+
|
112
|
+
require 'capistrano/systemd/multiservice'
|
113
|
+
install_plugin Capistrano::Systemd::MultiService.new('unicorn')
|
114
|
+
install_plugin Capistrano::Systemd::MultiService.new('delayed_job')
|
115
|
+
|
116
|
+
## ...snip...
|
117
|
+
```
|
118
|
+
|
119
|
+
#### `config/deploy.rb`
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
## ...snip...
|
123
|
+
|
124
|
+
set :systemd_delayed_job_instances, ->{ 3.times.to_a }
|
125
|
+
|
126
|
+
after 'deploy:restart', 'systemd:unicorn:reload-or-restart'
|
127
|
+
after 'deploy:restart', 'systemd:delayed_job:restart'
|
128
|
+
|
129
|
+
after 'deploy:publishing', 'deploy:restart'
|
130
|
+
|
131
|
+
## ...snip...
|
132
|
+
```
|
133
|
+
|
134
|
+
#### `config/systemd/unicorn.service.erb`
|
135
|
+
|
136
|
+
```
|
137
|
+
[Unit]
|
138
|
+
Description = <%= fetch(:application) %> unicorn rack server
|
139
|
+
|
140
|
+
[Service]
|
141
|
+
Environment = PATH=<%= fetch(:rbenv_path) %>/shims:/usr/local/bin:/usr/bin:/bin
|
142
|
+
Environment = RBENV_VERSION=<%= fetch(:rbenv_ruby) %>
|
143
|
+
Environment = RBENV_ROOT=<%= fetch(:rbenv_path) %>
|
144
|
+
Environment = RAILS_ENV=<%= fetch(:rails_env) %>
|
145
|
+
Environment = PWD=<%= current_path %>
|
146
|
+
|
147
|
+
WorkingDirectory = <%= current_path %>
|
148
|
+
|
149
|
+
ExecStart = <%= fetch(:rbenv_path) %>/bin/rbenv exec bundle exec unicorn -c <%= current_path %>/config/unicorn.rb
|
150
|
+
ExecReload = /bin/kill -USR2 $MAINPID
|
151
|
+
|
152
|
+
PIDFile = <%= shared_path %>/tmp/pids/unicorn.pid
|
153
|
+
KillSignal = SIGQUIT
|
154
|
+
KillMode = process
|
155
|
+
TimeoutStopSec = 62
|
156
|
+
Restart = always
|
157
|
+
|
158
|
+
User = app-user
|
159
|
+
Group = app-group
|
160
|
+
|
161
|
+
[Install]
|
162
|
+
WantedBy = multi-user.target
|
163
|
+
```
|
164
|
+
|
165
|
+
#### `config/systemd/delayed_job.service.erb`
|
166
|
+
|
167
|
+
```
|
168
|
+
[Unit]
|
169
|
+
Description = <%= fetch(:application) %> delayed_job
|
170
|
+
Requires = <%= fetch(:"#{prefix}_instance_services").join(" ") %>
|
171
|
+
|
172
|
+
[Service]
|
173
|
+
Type = oneshot
|
174
|
+
RemainAfterExit = yes
|
175
|
+
ExecStart = /bin/true
|
176
|
+
ExecReload = /bin/true
|
177
|
+
|
178
|
+
[Install]
|
179
|
+
WantedBy = multi-user.target
|
180
|
+
```
|
181
|
+
|
182
|
+
#### `config/systemd/delayed_job@.service.erb`
|
183
|
+
|
184
|
+
```
|
185
|
+
[Unit]
|
186
|
+
Description = <%= fetch(:application) %> delayed_job (instance %i)
|
187
|
+
PartOf = <%= fetch(:"#{prefix}_service") %>
|
188
|
+
ReloadPropagatedFrom = <%= fetch(:"#{prefix}_service") %>
|
189
|
+
|
190
|
+
[Service]
|
191
|
+
Type = forking
|
192
|
+
|
193
|
+
Environment = PATH=<%= fetch(:rbenv_path) %>/shims:/usr/local/bin:/usr/bin:/bin
|
194
|
+
Environment = RBENV_VERSION=<%= fetch(:rbenv_ruby) %>
|
195
|
+
Environment = RBENV_ROOT=<%= fetch(:rbenv_path) %>
|
196
|
+
Environment = RAILS_ENV=<%= fetch(:rails_env) %>
|
197
|
+
Environment = PWD=<%= current_path %>
|
198
|
+
|
199
|
+
WorkingDirectory = <%= current_path %>
|
200
|
+
|
201
|
+
ExecStart = <%= fetch(:rbenv_path) %>/bin/rbenv exec bundle exec bin/delayed_job -p <%= fetch(:application) %> -i %i start
|
202
|
+
ExecStop = <%= fetch(:rbenv_path) %>/bin/rbenv exec bundle exec bin/delayed_job -p <%= fetch(:application) %> -i %i stop
|
203
|
+
ExecReload = /bin/kill -HUP $MAINPID
|
204
|
+
|
205
|
+
PIDFile = <%= shared_path %>/tmp/pids/delayed_job.%i.pid
|
206
|
+
TimeoutStopSec = 22
|
207
|
+
Restart = always
|
208
|
+
|
209
|
+
User = app-user
|
210
|
+
Group = app-group
|
211
|
+
|
212
|
+
[Install]
|
213
|
+
WantedBy = multi-user.target
|
214
|
+
```
|
215
|
+
|
216
|
+
#### `config/unicorn.rb`
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
shared_path = "/path/to/shared"
|
220
|
+
|
221
|
+
worker_processes 5
|
222
|
+
listen "#{shared_path}/tmp/sockets/unicorn.sock"
|
223
|
+
pid "#{shared_path}/tmp/pids/unicorn.pid"
|
224
|
+
stderr_path "#{shared_path}/log/unicorn_stderr.log"
|
225
|
+
stdout_path "#{shared_path}/log/unicorn_stdout.log"
|
226
|
+
preload_app true
|
227
|
+
|
228
|
+
before_exec do |server|
|
229
|
+
ENV["BUNDLE_GEMFILE"] = "/path/to/current/Gemfile"
|
230
|
+
end
|
231
|
+
|
232
|
+
before_fork do |server, worker|
|
233
|
+
if defined? ActiveRecord::Base
|
234
|
+
ActiveRecord::Base.connection.disconnect!
|
235
|
+
end
|
236
|
+
|
237
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
238
|
+
if old_pid != server.pid
|
239
|
+
begin
|
240
|
+
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
|
241
|
+
Process.kill(sig, File.read(old_pid).to_i)
|
242
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
sleep 1
|
247
|
+
end
|
248
|
+
|
249
|
+
after_fork do |server, worker|
|
250
|
+
if defined?(ActiveRecord::Base)
|
251
|
+
ActiveRecord::Base.establish_connection
|
252
|
+
end
|
253
|
+
end
|
254
|
+
```
|
255
|
+
|
256
|
+
## Development
|
257
|
+
|
258
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
259
|
+
|
260
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
261
|
+
|
262
|
+
## Contributing
|
263
|
+
|
264
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/groovenauts/capistrano-systemd-multiservice.
|
265
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "capistrano/systemd/multiservice"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/systemd/multiservice/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capistrano-systemd-multiservice"
|
8
|
+
spec.version = Capistrano::Systemd::MultiService::VERSION
|
9
|
+
spec.authors = ["YAMADA Tsuyoshi"]
|
10
|
+
spec.email = ["tyamada@minimum2scp.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{Capistrano Plugin to control services by systemd}
|
13
|
+
spec.description = %q{Capistrano Plugin to control services by systemd}
|
14
|
+
spec.homepage = "https://github.com/groovenauts/capistrano-systemd-multiservice"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "capistrano", "~> 3.7.0"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "mocha", "~> 1.2"
|
29
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "stringio"
|
3
|
+
require "capistrano/plugin"
|
4
|
+
require "capistrano/systemd/multiservice/version"
|
5
|
+
|
6
|
+
module Capistrano
|
7
|
+
module Systemd
|
8
|
+
class MultiService < ::Capistrano::Plugin
|
9
|
+
attr_reader :app
|
10
|
+
|
11
|
+
def initialize(app)
|
12
|
+
@app = app
|
13
|
+
super()
|
14
|
+
end
|
15
|
+
|
16
|
+
def nsp
|
17
|
+
@app.to_sym
|
18
|
+
end
|
19
|
+
|
20
|
+
def prefix
|
21
|
+
"systemd_#{@app}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def define_tasks
|
25
|
+
eval_rakefile File.expand_path("../../tasks/systemd/multiservice.rake", __FILE__)
|
26
|
+
end
|
27
|
+
|
28
|
+
def register_hooks
|
29
|
+
after "deploy:check", "systemd:#{nsp}:validate"
|
30
|
+
after "systemd:#{nsp}:setup", "systemd:#{nsp}:daemon-reload"
|
31
|
+
after "systemd:#{nsp}:setup", "systemd:#{nsp}:enable"
|
32
|
+
before "systemd:#{nsp}:remove", "systemd:#{nsp}:disable"
|
33
|
+
after "systemd:#{nsp}:remove", "systemd:#{nsp}:daemon-reload"
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_defaults
|
37
|
+
set_if_empty :"#{prefix}_role", ->{ :app }
|
38
|
+
|
39
|
+
set_if_empty :"#{prefix}_units_src", ->{ Dir["config/systemd/#{@app}{,@}.*.erb"].sort }
|
40
|
+
|
41
|
+
set_if_empty :"#{prefix}_units_dir", ->{ "/etc/systemd/system" }
|
42
|
+
|
43
|
+
set_if_empty :"#{prefix}_units_dest", ->{
|
44
|
+
fetch(:"#{prefix}_units_src").map{|src|
|
45
|
+
"%s/%s_%s" % [ fetch(:"#{prefix}_units_dir"), fetch(:application), File.basename(src, ".erb") ]
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
set_if_empty :"#{prefix}_instances", ->{
|
50
|
+
if fetch(:"#{prefix}_units_dest").map{|dst| File.basename(dst) }.find{|f| f =~ /@\.service\z/ }
|
51
|
+
1.times.to_a
|
52
|
+
else
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
}
|
56
|
+
|
57
|
+
set_if_empty :"#{prefix}_service", ->{
|
58
|
+
service = fetch(:"#{prefix}_units_dest").map{|dst| File.basename(dst) }.find{|f| f =~ /\.service\z/ && f !~ /@\.service\z/ }
|
59
|
+
service || fetch(:"#{prefix}_instance_services")
|
60
|
+
}
|
61
|
+
|
62
|
+
set_if_empty :"#{prefix}_instance_services", ->{
|
63
|
+
if fetch(:"#{prefix}_instances")
|
64
|
+
fetch(:"#{prefix}_instances").map{|i|
|
65
|
+
service_template = fetch(:"#{prefix}_units_dest").map{|dst| File.basename(dst) }.find{|f| f =~ /@\.service\z/ }
|
66
|
+
service_template && service_template.sub(/@\.service\z/, "@#{i}.service")
|
67
|
+
}
|
68
|
+
else
|
69
|
+
[]
|
70
|
+
end
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def setup
|
75
|
+
fetch(:"#{prefix}_units_src").zip(fetch(:"#{prefix}_units_dest")).each do |src, dest|
|
76
|
+
remote_tmp = "#{fetch(:tmp_dir)}/#{File.basename(src, ".erb")}"
|
77
|
+
backend.upload! StringIO.new(ERB.new(File.read(src), nil, 2).result(binding)), remote_tmp
|
78
|
+
backend.sudo :install, '-m 644 -o root -g root -D', remote_tmp, dest
|
79
|
+
backend.execute :rm, remote_tmp
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def remove
|
84
|
+
backend.sudo :rm, '-f', '--', fetch(:"#{prefix}_units_dest")
|
85
|
+
end
|
86
|
+
|
87
|
+
def validate
|
88
|
+
fetch(:"#{prefix}_units_dest").each do |dest|
|
89
|
+
unless backend.test("[ -f #{dest} ]")
|
90
|
+
backend.error "#{dest} not found"
|
91
|
+
exit 1
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def daemon_reload
|
97
|
+
systemctl :"daemon-reload"
|
98
|
+
end
|
99
|
+
|
100
|
+
%i[start stop reload restart reload-or-restart enable disable].each do |act|
|
101
|
+
define_method act.to_s.tr('-','_') do
|
102
|
+
systemctl act, fetch(:"#{prefix}_service")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def systemctl(*args)
|
107
|
+
args.unshift :sudo, :systemctl
|
108
|
+
backend.execute(*args)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This trick lets us access the Capistrano::Systemd::MultiService plugin within `on` blocks
|
2
|
+
svc = self
|
3
|
+
|
4
|
+
namespace :systemd do
|
5
|
+
namespace svc.nsp do
|
6
|
+
{
|
7
|
+
setup: "Setup %{app} systemd unit file",
|
8
|
+
remove: "Remove %{app} systemd unit file",
|
9
|
+
validate: "Validate %{app} systemd unit file",
|
10
|
+
"daemon-reload": "Run systemctl daemon-reload",
|
11
|
+
start: "Run systemctl %{task_name} for %{app}",
|
12
|
+
stop: "Run systemctl %{task_name} for %{app}",
|
13
|
+
reload: "Run systemctl %{task_name} for %{app}",
|
14
|
+
restart: "Run systemctl %{task_name} for %{app}",
|
15
|
+
"reload-or-restart": "Run systemctl %{task_name} for %{app}",
|
16
|
+
enable: "Run systemctl %{task_name} for %{app}",
|
17
|
+
disable: "Run systemctl %{task_name} for %{app}",
|
18
|
+
}.each do |task_name, desc_template|
|
19
|
+
desc(desc_template % { app: svc.app, task_name: task_name})
|
20
|
+
task task_name do
|
21
|
+
on roles(fetch(:"#{svc.prefix}_role")) do
|
22
|
+
svc.__send__ task_name.to_s.tr('-', '_')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-systemd-multiservice
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.beta1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- YAMADA Tsuyoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
description: Capistrano Plugin to control services by systemd
|
84
|
+
email:
|
85
|
+
- tyamada@minimum2scp.org
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- capistrano-systemd-multiservice.gemspec
|
100
|
+
- lib/capistrano/systemd/multiservice.rb
|
101
|
+
- lib/capistrano/systemd/multiservice/version.rb
|
102
|
+
- lib/capistrano/tasks/systemd/multiservice.rake
|
103
|
+
homepage: https://github.com/groovenauts/capistrano-systemd-multiservice
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.3.1
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.4.5.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Capistrano Plugin to control services by systemd
|
127
|
+
test_files: []
|