foreman 0.81.0 → 0.82.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/export/systemd/process.service.erb +2 -1
- data/data/export/systemd/process_master.target.erb +0 -1
- data/lib/foreman/cli.rb +2 -1
- data/lib/foreman/engine.rb +1 -1
- data/lib/foreman/export/base.rb +11 -0
- data/lib/foreman/export/systemd.rb +17 -9
- data/lib/foreman/version.rb +1 -1
- data/man/foreman.1 +1 -1
- data/spec/foreman/export/systemd_spec.rb +32 -16
- data/spec/resources/export/systemd/app-alpha.target +2 -0
- data/spec/resources/export/systemd/{concurrency/app-alpha-1.service → app-alpha@.service} +2 -1
- data/spec/resources/export/systemd/app-bravo.target +2 -0
- data/spec/resources/export/systemd/{standard/app-bravo-1.service → app-bravo@.service} +2 -1
- data/spec/resources/export/systemd/{standard/app.target → app.target} +0 -0
- metadata +7 -11
- data/spec/resources/export/systemd/concurrency/app-alpha-2.service +0 -14
- data/spec/resources/export/systemd/concurrency/app-alpha.target +0 -3
- data/spec/resources/export/systemd/concurrency/app.target +0 -5
- data/spec/resources/export/systemd/standard/app-alpha-1.service +0 -14
- data/spec/resources/export/systemd/standard/app-alpha.target +0 -3
- data/spec/resources/export/systemd/standard/app-bravo.target +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6efd570b3be7d73416c5abf3ea05d1b77a542287
|
4
|
+
data.tar.gz: 9ffd849979688997a60c50584e8f43cdb5183c09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 196e4cdae6b750681ffae628c3315dfe256c1014cd60230495c66df36c006cfd5f263c8eebef61c6193d9fc5a977275133d4e2fa5a82c7da3e02c8f8d5a19a76
|
7
|
+
data.tar.gz: 2af37ab2769f9bde851d2946eaf3950ef9ce37c710bc3734efd6ad9726dbbb1faa96ef885d05a56ec76ec26c0312c234c497ecd590e5be79366ef8fbf4f81583
|
@@ -4,7 +4,7 @@ PartOf=<%= app %>-<%= name %>.target
|
|
4
4
|
[Service]
|
5
5
|
User=<%= user %>
|
6
6
|
WorkingDirectory=<%= engine.root %>
|
7
|
-
Environment=PORT
|
7
|
+
Environment=PORT=%i<% engine.env.each_pair do |var,env| %>
|
8
8
|
Environment=<%= var.upcase %>=<%= env %><% end %>
|
9
9
|
ExecStart=/bin/bash -lc '<%= process.command %>'
|
10
10
|
Restart=always
|
@@ -13,3 +13,4 @@ StandardOutput=syslog
|
|
13
13
|
StandardError=syslog
|
14
14
|
SyslogIdentifier=%n
|
15
15
|
KillMode=process
|
16
|
+
TimeoutStopSec=<%= engine.options[:timeout] %>
|
data/lib/foreman/cli.rb
CHANGED
@@ -50,7 +50,8 @@ class Foreman::CLI < Thor
|
|
50
50
|
method_option :port, :type => :numeric, :aliases => "-p"
|
51
51
|
method_option :user, :type => :string, :aliases => "-u"
|
52
52
|
method_option :template, :type => :string, :aliases => "-t"
|
53
|
-
method_option :
|
53
|
+
method_option :formation, :type => :string, :aliases => "-m", :banner => '"alpha=5,bar=3"', :desc => 'Specify what processes will run and how many. Default: "all=1"'
|
54
|
+
method_option :timeout, :type => :numeric, :aliases => "-t", :desc => "Specify the amount of time (in seconds) processes have to shutdown gracefully before receiving a SIGKILL, defaults to 5."
|
54
55
|
|
55
56
|
def export(format, location=nil)
|
56
57
|
check_procfile!
|
data/lib/foreman/engine.rb
CHANGED
data/lib/foreman/export/base.rb
CHANGED
@@ -100,6 +100,12 @@ private ######################################################################
|
|
100
100
|
FileUtils.rm(filename)
|
101
101
|
end
|
102
102
|
|
103
|
+
def clean_dir(dirname)
|
104
|
+
return unless File.exists?(dirname)
|
105
|
+
say "cleaning up directory: #{dirname}"
|
106
|
+
FileUtils.rm_r(dirname)
|
107
|
+
end
|
108
|
+
|
103
109
|
def shell_quote(value)
|
104
110
|
Shellwords.escape(value)
|
105
111
|
end
|
@@ -143,6 +149,11 @@ private ######################################################################
|
|
143
149
|
FileUtils.mkdir_p(File.join(location, dir))
|
144
150
|
end
|
145
151
|
|
152
|
+
def create_symlink(link, target)
|
153
|
+
say "symlinking: #{link} -> #{target}"
|
154
|
+
FileUtils.symlink(target, File.join(location, link))
|
155
|
+
end
|
156
|
+
|
146
157
|
def write_file(filename, contents)
|
147
158
|
say "writing: #{filename}"
|
148
159
|
|
@@ -6,21 +6,29 @@ class Foreman::Export::Systemd < Foreman::Export::Base
|
|
6
6
|
def export
|
7
7
|
super
|
8
8
|
|
9
|
-
Dir["#{location}/#{app}*.target"]
|
9
|
+
Dir["#{location}/#{app}*.target"]
|
10
|
+
.concat(Dir["#{location}/#{app}*.service"])
|
11
|
+
.concat(Dir["#{location}/#{app}*.target.wants/#{app}*.service"])
|
12
|
+
.each do |file|
|
10
13
|
clean file
|
11
14
|
end
|
12
15
|
|
16
|
+
Dir["#{location}/#{app}*.target.wants"].each do |file|
|
17
|
+
clean_dir file
|
18
|
+
end
|
19
|
+
|
13
20
|
process_master_names = []
|
14
21
|
|
15
22
|
engine.each_process do |name, process|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
1.upto(engine.formation[name])
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
service_fn = "#{app}-#{name}@.service"
|
24
|
+
write_template "systemd/process.service.erb", service_fn, binding
|
25
|
+
|
26
|
+
create_directory("#{app}-#{name}.target.wants")
|
27
|
+
1.upto(engine.formation[name])
|
28
|
+
.collect { |num| engine.port_for(process, num) }
|
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
|
24
32
|
end
|
25
33
|
|
26
34
|
write_template "systemd/process_master.target.erb", "#{app}-#{name}.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" "April 2016" "Foreman 0.
|
4
|
+
.TH "FOREMAN" "1" "April 2016" "Foreman 0.82.0" "Foreman Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBforeman\fR \- manage Procfile\-based applications
|
@@ -16,23 +16,39 @@ 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 eq(example_export_file("systemd/
|
20
|
-
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/
|
21
|
-
expect(File.read("/tmp/init/app-alpha
|
22
|
-
expect(File.read("/tmp/init/app-bravo.target")).to eq(example_export_file("systemd/
|
23
|
-
expect(File.read("/tmp/init/app-bravo
|
19
|
+
expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/app.target"))
|
20
|
+
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/app-alpha.target"))
|
21
|
+
expect(File.read("/tmp/init/app-alpha@.service")).to eq(example_export_file("systemd/app-alpha@.service"))
|
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
|
24
27
|
end
|
25
28
|
|
26
29
|
it "cleans up if exporting into an existing dir" do
|
27
30
|
mock(FileUtils).rm("/tmp/init/app.target")
|
31
|
+
|
32
|
+
mock(FileUtils).rm("/tmp/init/app-alpha@.service")
|
28
33
|
mock(FileUtils).rm("/tmp/init/app-alpha.target")
|
29
|
-
mock(FileUtils).rm("/tmp/init/app-alpha-
|
34
|
+
mock(FileUtils).rm("/tmp/init/app-alpha.target.wants/app-alpha@5000.service")
|
35
|
+
mock(FileUtils).rm_r("/tmp/init/app-alpha.target.wants")
|
36
|
+
|
30
37
|
mock(FileUtils).rm("/tmp/init/app-bravo.target")
|
31
|
-
mock(FileUtils).rm("/tmp/init/app-bravo
|
32
|
-
mock(FileUtils).rm("/tmp/init/app-
|
33
|
-
mock(FileUtils).
|
38
|
+
mock(FileUtils).rm("/tmp/init/app-bravo@.service")
|
39
|
+
mock(FileUtils).rm("/tmp/init/app-bravo.target.wants/app-bravo@5100.service")
|
40
|
+
mock(FileUtils).rm_r("/tmp/init/app-bravo.target.wants")
|
41
|
+
|
34
42
|
mock(FileUtils).rm("/tmp/init/app-foo_bar.target")
|
35
|
-
mock(FileUtils).rm("/tmp/init/app-foo_bar
|
43
|
+
mock(FileUtils).rm("/tmp/init/app-foo_bar@.service")
|
44
|
+
mock(FileUtils).rm("/tmp/init/app-foo_bar.target.wants/app-foo_bar@5200.service")
|
45
|
+
mock(FileUtils).rm_r("/tmp/init/app-foo_bar.target.wants")
|
46
|
+
|
47
|
+
mock(FileUtils).rm("/tmp/init/app-foo-bar.target")
|
48
|
+
mock(FileUtils).rm("/tmp/init/app-foo-bar@.service")
|
49
|
+
mock(FileUtils).rm("/tmp/init/app-foo-bar.target.wants/app-foo-bar@5300.service")
|
50
|
+
mock(FileUtils).rm_r("/tmp/init/app-foo-bar.target.wants")
|
51
|
+
|
36
52
|
|
37
53
|
systemd.export
|
38
54
|
systemd.export
|
@@ -41,7 +57,7 @@ describe Foreman::Export::Systemd, :fakefs do
|
|
41
57
|
it "includes environment variables" do
|
42
58
|
engine.env['KEY'] = 'some "value"'
|
43
59
|
systemd.export
|
44
|
-
expect(File.read("/tmp/init/app-alpha
|
60
|
+
expect(File.read("/tmp/init/app-alpha@.service")).to match(/KEY=some "value"$/)
|
45
61
|
end
|
46
62
|
|
47
63
|
context "with a formation" do
|
@@ -50,11 +66,11 @@ describe Foreman::Export::Systemd, :fakefs do
|
|
50
66
|
it "exports to the filesystem with concurrency" do
|
51
67
|
systemd.export
|
52
68
|
|
53
|
-
expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/
|
54
|
-
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/
|
55
|
-
expect(File.read("/tmp/init/app-alpha
|
56
|
-
expect(File.read("/tmp/init/app-
|
57
|
-
expect(File.
|
69
|
+
expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/app.target"))
|
70
|
+
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/app-alpha.target"))
|
71
|
+
expect(File.read("/tmp/init/app-alpha@.service")).to eq(example_export_file("systemd/app-alpha@.service"))
|
72
|
+
expect(File.read("/tmp/init/app-bravo.target")).to eq(example_export_file("systemd/app-bravo.target"))
|
73
|
+
expect(File.read("/tmp/init/app-bravo@.service")).to eq(example_export_file("systemd/app-bravo@.service"))
|
58
74
|
end
|
59
75
|
end
|
60
76
|
|
@@ -4,7 +4,7 @@ PartOf=app-alpha.target
|
|
4
4
|
[Service]
|
5
5
|
User=app
|
6
6
|
WorkingDirectory=/tmp/app
|
7
|
-
Environment=PORT
|
7
|
+
Environment=PORT=%i
|
8
8
|
ExecStart=/bin/bash -lc './alpha'
|
9
9
|
Restart=always
|
10
10
|
StandardInput=null
|
@@ -12,3 +12,4 @@ StandardOutput=syslog
|
|
12
12
|
StandardError=syslog
|
13
13
|
SyslogIdentifier=%n
|
14
14
|
KillMode=process
|
15
|
+
TimeoutStopSec=5
|
@@ -4,7 +4,7 @@ PartOf=app-bravo.target
|
|
4
4
|
[Service]
|
5
5
|
User=app
|
6
6
|
WorkingDirectory=/tmp/app
|
7
|
-
Environment=PORT
|
7
|
+
Environment=PORT=%i
|
8
8
|
ExecStart=/bin/bash -lc './bravo'
|
9
9
|
Restart=always
|
10
10
|
StandardInput=null
|
@@ -12,3 +12,4 @@ StandardOutput=syslog
|
|
12
12
|
StandardError=syslog
|
13
13
|
SyslogIdentifier=%n
|
14
14
|
KillMode=process
|
15
|
+
TimeoutStopSec=5
|
File without changes
|
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.82.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: 2016-
|
11
|
+
date: 2016-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -121,15 +121,11 @@ files:
|
|
121
121
|
- spec/resources/export/runit/app-bravo-1/run
|
122
122
|
- spec/resources/export/supervisord/app-alpha-1.conf
|
123
123
|
- spec/resources/export/supervisord/app-alpha-2.conf
|
124
|
-
- spec/resources/export/systemd/
|
125
|
-
- spec/resources/export/systemd/
|
126
|
-
- spec/resources/export/systemd/
|
127
|
-
- spec/resources/export/systemd/
|
128
|
-
- spec/resources/export/systemd/
|
129
|
-
- spec/resources/export/systemd/standard/app-alpha.target
|
130
|
-
- spec/resources/export/systemd/standard/app-bravo-1.service
|
131
|
-
- spec/resources/export/systemd/standard/app-bravo.target
|
132
|
-
- spec/resources/export/systemd/standard/app.target
|
124
|
+
- spec/resources/export/systemd/app-alpha.target
|
125
|
+
- spec/resources/export/systemd/app-alpha@.service
|
126
|
+
- spec/resources/export/systemd/app-bravo.target
|
127
|
+
- spec/resources/export/systemd/app-bravo@.service
|
128
|
+
- spec/resources/export/systemd/app.target
|
133
129
|
- spec/resources/export/upstart/app-alpha-1.conf
|
134
130
|
- spec/resources/export/upstart/app-alpha-2.conf
|
135
131
|
- spec/resources/export/upstart/app-alpha.conf
|
@@ -1,14 +0,0 @@
|
|
1
|
-
[Unit]
|
2
|
-
PartOf=app-alpha.target
|
3
|
-
|
4
|
-
[Service]
|
5
|
-
User=app
|
6
|
-
WorkingDirectory=/tmp/app
|
7
|
-
Environment=PORT=5001
|
8
|
-
ExecStart=/bin/bash -lc './alpha'
|
9
|
-
Restart=always
|
10
|
-
StandardInput=null
|
11
|
-
StandardOutput=syslog
|
12
|
-
StandardError=syslog
|
13
|
-
SyslogIdentifier=%n
|
14
|
-
KillMode=process
|
@@ -1,14 +0,0 @@
|
|
1
|
-
[Unit]
|
2
|
-
PartOf=app-alpha.target
|
3
|
-
|
4
|
-
[Service]
|
5
|
-
User=app
|
6
|
-
WorkingDirectory=/tmp/app
|
7
|
-
Environment=PORT=5000
|
8
|
-
ExecStart=/bin/bash -lc './alpha'
|
9
|
-
Restart=always
|
10
|
-
StandardInput=null
|
11
|
-
StandardOutput=syslog
|
12
|
-
StandardError=syslog
|
13
|
-
SyslogIdentifier=%n
|
14
|
-
KillMode=process
|