foreman 0.86.0 → 0.87.0
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.
- checksums.yaml +4 -4
- data/data/export/systemd/master.target.erb +1 -1
- data/data/export/systemd/process.service.erb +6 -3
- data/lib/foreman/export/systemd.rb +7 -13
- data/lib/foreman/version.rb +1 -1
- data/man/foreman.1 +1 -1
- data/spec/foreman/export/systemd_spec.rb +88 -46
- data/spec/resources/export/systemd/{app-alpha@.service → app-alpha.1.service} +6 -3
- data/spec/resources/export/systemd/{app-bravo@.service → app-alpha.2.service} +6 -3
- data/spec/resources/export/systemd/app-bravo.1.service +18 -0
- data/spec/resources/export/systemd/app.target +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +5 -5
- data/data/export/systemd/process_master.target.erb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4561719e71efe2d57cb77e271499273d03dd6e3ce1566c2ea448b9924f3986b
|
4
|
+
data.tar.gz: 317cb62ea6013742326098d8e4942aafaed4f3c8ba1eee63bf52c269c514d3b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5af45a820751188c14a474634687b8a088aa436c0de20cf828e1ced1f3c4cdec51da0f6e1566dc78a0f04faa1f14c8a5e516005d96a0abc3c5833e689dd2d217
|
7
|
+
data.tar.gz: a35df2258df75633fdeb5835e5f6d82290be0c7c573fac3b2da482c9d61565db7acea6e80c6d1b0663b11924b825139502c0553d231f941a2fa0033cf7cee85a
|
@@ -1,15 +1,18 @@
|
|
1
1
|
[Unit]
|
2
|
-
PartOf=<%= app
|
2
|
+
PartOf=<%= app %>.target
|
3
|
+
StopWhenUnneeded=yes
|
3
4
|
|
4
5
|
[Service]
|
5
6
|
User=<%= user %>
|
6
7
|
WorkingDirectory=<%= engine.root %>
|
7
|
-
Environment=PORT
|
8
|
+
Environment=PORT=<%= port %>
|
9
|
+
Environment=PS=<%= process_name %>
|
8
10
|
<% engine.env.each_pair do |var,env| -%>
|
9
11
|
Environment="<%= var %>=<%= env %>"
|
10
12
|
<% end -%>
|
11
|
-
ExecStart=/bin/bash -lc 'exec <%= process.command %>'
|
13
|
+
ExecStart=/bin/bash -lc 'exec -a "<%= app %>-<%= process_name %>" <%= process.command %>'
|
12
14
|
Restart=always
|
15
|
+
RestartSec=14s
|
13
16
|
StandardInput=null
|
14
17
|
StandardOutput=syslog
|
15
18
|
StandardError=syslog
|
@@ -17,22 +17,16 @@ class Foreman::Export::Systemd < Foreman::Export::Base
|
|
17
17
|
clean_dir file
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
service_names = []
|
21
21
|
|
22
22
|
engine.each_process do |name, process|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
.collect { |port| "#{app}-#{name}@#{port}.service" }
|
30
|
-
.each do |process_name|
|
31
|
-
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
|
23
|
+
1.upto(engine.formation[name]) do |num|
|
24
|
+
port = engine.port_for(process, num)
|
25
|
+
process_name = "#{name}.#{num}"
|
26
|
+
service_filename = "#{app}-#{process_name}.service"
|
27
|
+
write_template "systemd/process.service.erb", service_filename, binding
|
28
|
+
service_names << service_filename
|
32
29
|
end
|
33
|
-
|
34
|
-
write_template "systemd/process_master.target.erb", "#{app}-#{name}.target", binding
|
35
|
-
process_master_names << "#{app}-#{name}.target"
|
36
30
|
end
|
37
31
|
|
38
32
|
write_template "systemd/master.target.erb", "#{app}.target", binding
|
data/lib/foreman/version.rb
CHANGED
data/man/foreman.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "FOREMAN" "1" "
|
4
|
+
.TH "FOREMAN" "1" "January 2020" "Foreman 0.87.0" "Foreman Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBforeman\fR \- manage Procfile\-based applications
|
@@ -3,7 +3,7 @@ require "foreman/engine"
|
|
3
3
|
require "foreman/export/systemd"
|
4
4
|
require "tmpdir"
|
5
5
|
|
6
|
-
describe Foreman::Export::Systemd, :fakefs do
|
6
|
+
describe Foreman::Export::Systemd, :fakefs, :aggregate_failures do
|
7
7
|
let(:procfile) { write_procfile("/tmp/app/Procfile") }
|
8
8
|
let(:formation) { nil }
|
9
9
|
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
|
@@ -16,71 +16,101 @@ describe Foreman::Export::Systemd, :fakefs do
|
|
16
16
|
it "exports to the filesystem" do
|
17
17
|
systemd.export
|
18
18
|
|
19
|
-
expect(File.read("/tmp/init/app.target")).to
|
20
|
-
expect(File.read("/tmp/init/app-alpha.
|
21
|
-
expect(File.read("/tmp/init/app-
|
22
|
-
expect(File.read("/tmp/init/app-bravo.target")).to eq(example_export_file("systemd/app-bravo.target"))
|
23
|
-
expect(File.read("/tmp/init/app-bravo@.service")).to eq(example_export_file("systemd/app-bravo@.service"))
|
24
|
-
|
25
|
-
expect(File.directory?("/tmp/init/app-alpha.target.wants")).to be_truthy
|
26
|
-
expect(File.symlink?("/tmp/init/app-alpha.target.wants/app-alpha@5000.service")).to be_truthy
|
19
|
+
expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/app.target"))
|
20
|
+
expect(File.read("/tmp/init/app-alpha.1.service")).to eq(example_export_file("systemd/app-alpha.1.service"))
|
21
|
+
expect(File.read("/tmp/init/app-bravo.1.service")).to eq(example_export_file("systemd/app-bravo.1.service"))
|
27
22
|
end
|
28
23
|
|
29
|
-
|
30
|
-
|
24
|
+
context "when systemd export was run using the previous version of systemd export" do
|
25
|
+
before do
|
26
|
+
write_file("/tmp/init/app.target")
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-alpha.target.wants")
|
28
|
+
write_file("/tmp/init/app-alpha@.service")
|
29
|
+
write_file("/tmp/init/app-alpha.target")
|
30
|
+
write_file("/tmp/init/app-alpha.target.wants/app-alpha@5000.service")
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-bravo.target.wants")
|
32
|
+
write_file("/tmp/init/app-bravo.target")
|
33
|
+
write_file("/tmp/init/app-bravo@.service")
|
34
|
+
write_file("/tmp/init/app-bravo.target.wants/app-bravo@5100.service")
|
41
35
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-foo_bar.target.wants")
|
36
|
+
write_file("/tmp/init/app-foo_bar.target")
|
37
|
+
write_file("/tmp/init/app-foo_bar@.service")
|
38
|
+
write_file("/tmp/init/app-foo_bar.target.wants/app-foo_bar@5200.service")
|
46
39
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
40
|
+
write_file("/tmp/init/app-foo-bar.target")
|
41
|
+
write_file("/tmp/init/app-foo-bar@.service")
|
42
|
+
write_file("/tmp/init/app-foo-bar.target.wants/app-foo-bar@5300.service")
|
43
|
+
end
|
51
44
|
|
45
|
+
it "cleans up service files created by systemd export" do
|
46
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app.target")
|
52
47
|
|
53
|
-
|
54
|
-
|
48
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-alpha@.service")
|
49
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-alpha.target")
|
50
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-alpha.target.wants/app-alpha@5000.service")
|
51
|
+
expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-alpha.target.wants")
|
52
|
+
|
53
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-bravo.target")
|
54
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-bravo@.service")
|
55
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-bravo.target.wants/app-bravo@5100.service")
|
56
|
+
expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-bravo.target.wants")
|
57
|
+
|
58
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo_bar.target")
|
59
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo_bar@.service")
|
60
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo_bar.target.wants/app-foo_bar@5200.service")
|
61
|
+
expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-foo_bar.target.wants")
|
62
|
+
|
63
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo-bar.target")
|
64
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo-bar@.service")
|
65
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo-bar.target.wants/app-foo-bar@5300.service")
|
66
|
+
expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-foo-bar.target.wants")
|
67
|
+
|
68
|
+
systemd.export
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when systemd export was run using the current version of systemd export" do
|
73
|
+
before do
|
74
|
+
systemd.export
|
75
|
+
end
|
76
|
+
|
77
|
+
it "cleans up service files created by systemd export" do
|
78
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app.target")
|
79
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-alpha.1.service")
|
80
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-bravo.1.service")
|
81
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo_bar.1.service")
|
82
|
+
expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo-bar.1.service")
|
83
|
+
|
84
|
+
systemd.export
|
85
|
+
end
|
55
86
|
end
|
56
87
|
|
57
88
|
it "includes environment variables" do
|
58
89
|
engine.env['KEY'] = 'some "value"'
|
59
90
|
systemd.export
|
60
|
-
expect(File.read("/tmp/init/app-alpha
|
91
|
+
expect(File.read("/tmp/init/app-alpha.1.service")).to match(/KEY=some "value"/)
|
61
92
|
end
|
62
93
|
|
63
94
|
it "includes ExecStart line" do
|
64
95
|
engine.env['KEY'] = 'some "value"'
|
65
96
|
systemd.export
|
66
|
-
expect(File.read("/tmp/init/app-alpha
|
97
|
+
expect(File.read("/tmp/init/app-alpha.1.service")).to match(/^ExecStart=/)
|
67
98
|
end
|
68
99
|
|
69
|
-
context "with a formation" do
|
100
|
+
context "with a custom formation specified" do
|
70
101
|
let(:formation) { "alpha=2" }
|
71
102
|
|
72
|
-
it "exports
|
103
|
+
it "exports only those services that are specified in the formation" do
|
73
104
|
systemd.export
|
74
105
|
|
75
|
-
expect(File.read("/tmp/init/app.target")).to
|
76
|
-
expect(File.read("/tmp/init/app-alpha.
|
77
|
-
expect(File.read("/tmp/init/app-alpha
|
78
|
-
expect(File.
|
79
|
-
expect(File.read("/tmp/init/app-bravo@.service")).to eq(example_export_file("systemd/app-bravo@.service"))
|
106
|
+
expect(File.read("/tmp/init/app.target")).to include("Wants=app-alpha.1.service app-alpha.2.service\n")
|
107
|
+
expect(File.read("/tmp/init/app-alpha.1.service")).to eq(example_export_file("systemd/app-alpha.1.service"))
|
108
|
+
expect(File.read("/tmp/init/app-alpha.2.service")).to eq(example_export_file("systemd/app-alpha.2.service"))
|
109
|
+
expect(File.exist?("/tmp/init/app-bravo.1.service")).to be_falsey
|
80
110
|
end
|
81
111
|
end
|
82
112
|
|
83
|
-
context "with alternate
|
113
|
+
context "with alternate template directory specified" do
|
84
114
|
let(:template) { "/tmp/alternate" }
|
85
115
|
let(:options) { { :app => "app", :template => template } }
|
86
116
|
|
@@ -89,25 +119,37 @@ describe Foreman::Export::Systemd, :fakefs do
|
|
89
119
|
File.open("#{template}/master.target.erb", "w") { |f| f.puts "alternate_template" }
|
90
120
|
end
|
91
121
|
|
92
|
-
it "
|
122
|
+
it "uses template files found in the alternate directory" do
|
93
123
|
systemd.export
|
94
124
|
expect(File.read("/tmp/init/app.target")).to eq("alternate_template\n")
|
95
125
|
end
|
96
|
-
end
|
97
126
|
|
98
|
-
|
127
|
+
context "with alternate templates in the user home directory" do
|
128
|
+
before do
|
129
|
+
FileUtils.mkdir_p File.expand_path("~/.foreman/templates/systemd")
|
130
|
+
File.open(File.expand_path("~/.foreman/templates/systemd/master.target.erb"), "w") do |file|
|
131
|
+
file.puts "home_dir_template"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
it "uses template files found in the alternate directory" do
|
136
|
+
systemd.export
|
137
|
+
expect(File.read("/tmp/init/app.target")).to eq("alternate_template\n")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
99
141
|
|
142
|
+
context "with alternate templates in the user home directory" do
|
100
143
|
before do
|
101
144
|
FileUtils.mkdir_p File.expand_path("~/.foreman/templates/systemd")
|
102
145
|
File.open(File.expand_path("~/.foreman/templates/systemd/master.target.erb"), "w") do |file|
|
103
|
-
file.puts "
|
146
|
+
file.puts "home_dir_template"
|
104
147
|
end
|
105
148
|
end
|
106
149
|
|
107
|
-
it "
|
150
|
+
it "uses template files found in the user home directory" do
|
108
151
|
systemd.export
|
109
|
-
expect(File.read("/tmp/init/app.target")).to eq("
|
152
|
+
expect(File.read("/tmp/init/app.target")).to eq("home_dir_template\n")
|
110
153
|
end
|
111
154
|
end
|
112
|
-
|
113
155
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
[Unit]
|
2
|
-
PartOf=app
|
2
|
+
PartOf=app.target
|
3
|
+
StopWhenUnneeded=yes
|
3
4
|
|
4
5
|
[Service]
|
5
6
|
User=app
|
6
7
|
WorkingDirectory=/tmp/app
|
7
|
-
Environment=PORT
|
8
|
-
|
8
|
+
Environment=PORT=5000
|
9
|
+
Environment=PS=alpha.1
|
10
|
+
ExecStart=/bin/bash -lc 'exec -a "app-alpha.1" ./alpha'
|
9
11
|
Restart=always
|
12
|
+
RestartSec=14s
|
10
13
|
StandardInput=null
|
11
14
|
StandardOutput=syslog
|
12
15
|
StandardError=syslog
|
@@ -1,12 +1,15 @@
|
|
1
1
|
[Unit]
|
2
|
-
PartOf=app
|
2
|
+
PartOf=app.target
|
3
|
+
StopWhenUnneeded=yes
|
3
4
|
|
4
5
|
[Service]
|
5
6
|
User=app
|
6
7
|
WorkingDirectory=/tmp/app
|
7
|
-
Environment=PORT
|
8
|
-
|
8
|
+
Environment=PORT=5001
|
9
|
+
Environment=PS=alpha.2
|
10
|
+
ExecStart=/bin/bash -lc 'exec -a "app-alpha.2" ./alpha'
|
9
11
|
Restart=always
|
12
|
+
RestartSec=14s
|
10
13
|
StandardInput=null
|
11
14
|
StandardOutput=syslog
|
12
15
|
StandardError=syslog
|
@@ -0,0 +1,18 @@
|
|
1
|
+
[Unit]
|
2
|
+
PartOf=app.target
|
3
|
+
StopWhenUnneeded=yes
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
User=app
|
7
|
+
WorkingDirectory=/tmp/app
|
8
|
+
Environment=PORT=5100
|
9
|
+
Environment=PS=bravo.1
|
10
|
+
ExecStart=/bin/bash -lc 'exec -a "app-bravo.1" ./bravo'
|
11
|
+
Restart=always
|
12
|
+
RestartSec=14s
|
13
|
+
StandardInput=null
|
14
|
+
StandardOutput=syslog
|
15
|
+
StandardError=syslog
|
16
|
+
SyslogIdentifier=%n
|
17
|
+
KillMode=mixed
|
18
|
+
TimeoutStopSec=5
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.87.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Dollar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Process manager for applications with multiple components
|
14
14
|
email: ddollar@gmail.com
|
@@ -38,7 +38,6 @@ files:
|
|
38
38
|
- data/export/supervisord/app.conf.erb
|
39
39
|
- data/export/systemd/master.target.erb
|
40
40
|
- data/export/systemd/process.service.erb
|
41
|
-
- data/export/systemd/process_master.target.erb
|
42
41
|
- data/export/upstart/master.conf.erb
|
43
42
|
- data/export/upstart/process.conf.erb
|
44
43
|
- data/export/upstart/process_master.conf.erb
|
@@ -139,10 +138,11 @@ files:
|
|
139
138
|
- spec/resources/export/runit/app-bravo-1/run
|
140
139
|
- spec/resources/export/supervisord/app-alpha-1.conf
|
141
140
|
- spec/resources/export/supervisord/app-alpha-2.conf
|
141
|
+
- spec/resources/export/systemd/app-alpha.1.service
|
142
|
+
- spec/resources/export/systemd/app-alpha.2.service
|
142
143
|
- spec/resources/export/systemd/app-alpha.target
|
143
|
-
- spec/resources/export/systemd/app-
|
144
|
+
- spec/resources/export/systemd/app-bravo.1.service
|
144
145
|
- spec/resources/export/systemd/app-bravo.target
|
145
|
-
- spec/resources/export/systemd/app-bravo@.service
|
146
146
|
- spec/resources/export/systemd/app.target
|
147
147
|
- spec/resources/export/upstart/app-alpha-1.conf
|
148
148
|
- spec/resources/export/upstart/app-alpha-2.conf
|