foreman-export-systemd_user 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b66872969d8490ee1ff0d296d53df30906af0b12
4
+ data.tar.gz: bdfe324dbea0df02ba61b0ccea203d5d0dc57400
5
+ SHA512:
6
+ metadata.gz: 78553e62711daf780ca86535111eea9fa86a833b737b8e10b9bacc091c0fb646013314457cdbc368fcb2f5afc6dd0b1027d5da259fe8cc82f006ad170f55cb48
7
+ data.tar.gz: 55e358b780bb823dd895b7a8582e8832eb08c390e2cf028882f146bcebda1f2f46e1605206af1efb72545ed6a942ee9cc135fa98ca271095bad6578adaffcc1d
@@ -0,0 +1,2 @@
1
+ pkg/
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining
2
+ a copy of this software and associated documentation files (the
3
+ "Software"), to deal in the Software without restriction, including
4
+ without limitation the rights to use, copy, modify, merge, publish,
5
+ distribute, sublicense, and/or sell copies of the Software, and to
6
+ permit persons to whom the Software is furnished to do so, subject to
7
+ the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be
10
+ included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ # Foreman export scripts for user-level systemd on Ubuntu 16.04
2
+
3
+ ```ruby
4
+ # Gemfile
5
+ gem "foreman-export-systemd_user"
6
+ ```
7
+
8
+ then
9
+
10
+ ```
11
+ bundle exec foreman export systemd-user --app <app-name>
12
+ systemctl --user enable <app-name>.target
13
+ systemctl --user start <app-name>.target
14
+ ```
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ [Unit]
2
+ Wants=<%= process_master_names.join(' ') %>
3
+
4
+ [Install]
5
+ WantedBy=default.target
6
+
@@ -0,0 +1,15 @@
1
+ [Unit]
2
+ PartOf=<%= app %>-<%= name %>.target
3
+
4
+ [Service]
5
+ WorkingDirectory=<%= engine.root %>
6
+ Environment=PORT=%i
7
+ <% if !engine.env.empty? -%>Environment=<% engine.env.each_pair do |var,env| %>"<%= var.upcase %>=<%= env %>" <% end %><% end -%>
8
+ ExecStart=/bin/bash -lic '<%= process.command %>'
9
+ Restart=always
10
+ StandardInput=null
11
+ StandardOutput=syslog
12
+ StandardError=syslog
13
+ SyslogIdentifier=%n
14
+ KillMode=mixed
15
+ TimeoutStopSec=<%= engine.options[:timeout] %>
@@ -0,0 +1,18 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "foreman-export-systemd_user"
5
+ s.version = "0.0.1"
6
+ s.authors = ["Micah Geisel"]
7
+ s.email = ["micah@botandrose.com"]
8
+ s.homepage = "http://github.com/botandrose/foreman-export-systemd_user"
9
+ s.summary = "Upstart user-level export scripts for systemd on Ubuntu 16.04+"
10
+ s.description = "Upstart user-level export scripts for systemd on Ubuntu 16.04+"
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ s.require_paths = ["lib"]
16
+
17
+ s.add_runtime_dependency "foreman"
18
+ end
@@ -0,0 +1,4 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require "foreman/export/systemd_user"
4
+
@@ -0,0 +1,57 @@
1
+ require "erb"
2
+ require "foreman/export"
3
+
4
+ class Foreman::Export::SystemdUser < Foreman::Export::Base
5
+ def initialize location, engine, options={}
6
+ super
7
+ # what a pain in the ass
8
+ # template is obviously not intended to be overriden
9
+ unless @options.has_key?(:template)
10
+ template = File.expand_path("../../../../data/export/systemd_user", __FILE__)
11
+ @options = { template: template }.merge(@options).freeze
12
+ end
13
+ end
14
+
15
+ def app
16
+ options[:app] || File.basename(FileUtils.pwd)
17
+ end
18
+
19
+ def location
20
+ super || "#{ENV["HOME"]}/.config/systemd/user"
21
+ end
22
+
23
+ def export
24
+ super
25
+
26
+ Dir["#{location}/#{app}*.target"]
27
+ .concat(Dir["#{location}/#{app}*.service"])
28
+ .concat(Dir["#{location}/#{app}*.target.wants/#{app}*.service"])
29
+ .each do |file|
30
+ clean file
31
+ end
32
+
33
+ Dir["#{location}/#{app}*.target.wants"].each do |file|
34
+ clean_dir file
35
+ end
36
+
37
+ process_master_names = []
38
+
39
+ engine.each_process do |name, process|
40
+ service_fn = "#{app}-#{name}@.service"
41
+ write_template "systemd_user/process.service.erb", service_fn, binding
42
+
43
+ create_directory("#{app}-#{name}.target.wants")
44
+ 1.upto(engine.formation[name])
45
+ .collect { |num| engine.port_for(process, num) }
46
+ .collect { |port| "#{app}-#{name}@#{port}.service" }
47
+ .each do |process_name|
48
+ create_symlink("#{app}-#{name}.target.wants/#{process_name}", "../#{service_fn}") rescue Errno::EEXIST # This is needed because rr-mocks do not call the origial cleanup
49
+ end
50
+
51
+ write_template "systemd/process_master.target.erb", "#{app}-#{name}.target", binding
52
+ process_master_names << "#{app}-#{name}.target"
53
+ end
54
+
55
+ write_template "systemd_user/master.target.erb", "#{app}.target", binding
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman-export-systemd_user
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Micah Geisel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: foreman
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Upstart user-level export scripts for systemd on Ubuntu 16.04+
28
+ email:
29
+ - micah@botandrose.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE
37
+ - README.md
38
+ - Rakefile
39
+ - data/export/systemd_user/master.target.erb
40
+ - data/export/systemd_user/process.service.erb
41
+ - foreman-export-systemd_user.gemspec
42
+ - lib/foreman-export-systemd_user.rb
43
+ - lib/foreman/export/systemd_user.rb
44
+ homepage: http://github.com/botandrose/foreman-export-systemd_user
45
+ licenses: []
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.4.6
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Upstart user-level export scripts for systemd on Ubuntu 16.04+
67
+ test_files: []