capistrano-systemd-multiservice 0.1.0.beta6 → 0.1.0.beta7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d87bd65e266039237728db3acbb868d1025178754075fcabca743a200f451951
|
4
|
+
data.tar.gz: fdb1a701734aa0b50d71b7b8b76354f9474377e58c99778b68a3a54a5d313b70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78e256f02d99a5438bd08323cd77d0e9c93712e3682ec58a956dbf41bec6400770606881ebf96b84f2467864dae84c67365bcdf2e75a744c254919cbe8c11630
|
7
|
+
data.tar.gz: 19193bc630872b81e359625438aa9abb1c4a86d57aaa23cb4808dd774e8d009292a41579fc1864ed5d3b7bbb4f7b5f7592c849e2ec95dc1e15fe4d523bbd39f1
|
data/README.md
CHANGED
@@ -68,6 +68,20 @@ cap STAGE systemd:example1:setup systemd:example2:setup
|
|
68
68
|
cap STAGE deploy
|
69
69
|
```
|
70
70
|
|
71
|
+
### User services
|
72
|
+
|
73
|
+
To have the service installed under your own user rather than root
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
require "capistrano/systemd/multiservice"
|
77
|
+
install_plugin Capistrano::Systemd::MultiService.new_service("example1", service_type: 'user')
|
78
|
+
install_plugin Capistrano::Systemd::MultiService.new_service("example2", service_type: 'user')
|
79
|
+
```
|
80
|
+
|
81
|
+
If using the user service type services will be installed in your users home directory under ``` /.config/systemd/user ```.
|
82
|
+
Systemd commands on those services can be run by passing a `--user` flag, e.g. ```systemctl --user list-unit-files```
|
83
|
+
Nothing else in setup should require change and Capistrano tasks should remain the same as when installing system services.
|
84
|
+
|
71
85
|
## Capistrano Tasks
|
72
86
|
|
73
87
|
With `install_plugin Capistrano::Systemd::MultiService.new_service("example1")`,
|
@@ -1,11 +1,22 @@
|
|
1
1
|
require "capistrano/systemd/multiservice/version"
|
2
2
|
require "capistrano/systemd/multiservice/system_service"
|
3
|
+
require "capistrano/systemd/multiservice/user_service"
|
3
4
|
|
4
5
|
module Capistrano
|
5
6
|
module Systemd
|
6
7
|
module MultiService
|
7
|
-
|
8
|
-
|
8
|
+
SERVICE_TYPES = %w[system user].freeze
|
9
|
+
|
10
|
+
class ServiceTypeError < RuntimeError; end
|
11
|
+
|
12
|
+
def self.new_service(app, service_type: 'system')
|
13
|
+
service_type = service_type.to_s
|
14
|
+
unless SERVICE_TYPES.include?(service_type)
|
15
|
+
raise ServiceTypeError,
|
16
|
+
"Service type has to be one of #{SERVICE_TYPES}"
|
17
|
+
end
|
18
|
+
|
19
|
+
const_get("#{service_type.capitalize}Service").new(app)
|
9
20
|
end
|
10
21
|
end
|
11
22
|
end
|
@@ -71,6 +71,10 @@ module Capistrano
|
|
71
71
|
}
|
72
72
|
end
|
73
73
|
|
74
|
+
def default_units_dir
|
75
|
+
"/etc/systemd/system"
|
76
|
+
end
|
77
|
+
|
74
78
|
def setup
|
75
79
|
fetch(:"#{prefix}_units_src").zip(fetch(:"#{prefix}_units_dest")).each do |src, dest|
|
76
80
|
buf = StringIO.new(ERB.new(File.read(src), nil, 2).result(binding))
|
@@ -106,10 +110,6 @@ module Capistrano
|
|
106
110
|
backend.execute(*args)
|
107
111
|
end
|
108
112
|
|
109
|
-
def default_units_dir
|
110
|
-
"/etc/systemd/system"
|
111
|
-
end
|
112
|
-
|
113
113
|
private
|
114
114
|
|
115
115
|
def setup_service(buf, src, dest)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative './system_service'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
module Systemd
|
5
|
+
module MultiService
|
6
|
+
class UserService < SystemService
|
7
|
+
def systemctl(*args)
|
8
|
+
args.unshift :systemctl, '--user'
|
9
|
+
backend.execute(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def remove
|
13
|
+
backend.execute :rm, '-f', '--', fetch(:"#{prefix}_units_dest")
|
14
|
+
end
|
15
|
+
|
16
|
+
def default_units_dir
|
17
|
+
"/home/#{fetch(:user)}/.config/systemd/user"
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def setup_service(buf, src, dest)
|
23
|
+
backend.upload! buf, dest
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-systemd-multiservice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.beta7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YAMADA Tsuyoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- capistrano-systemd-multiservice.gemspec
|
106
106
|
- lib/capistrano/systemd/multiservice.rb
|
107
107
|
- lib/capistrano/systemd/multiservice/system_service.rb
|
108
|
+
- lib/capistrano/systemd/multiservice/user_service.rb
|
108
109
|
- lib/capistrano/systemd/multiservice/version.rb
|
109
110
|
- lib/capistrano/tasks/systemd/multiservice/system_service.rake
|
110
111
|
homepage: https://github.com/groovenauts/capistrano-systemd-multiservice
|