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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fdde51adad323e0a4c3687d58aa3fd9a83fcbea
4
- data.tar.gz: b9cbfb3dd2784599d8177ecdca3c6f1803d2e505
3
+ metadata.gz: 6efd570b3be7d73416c5abf3ea05d1b77a542287
4
+ data.tar.gz: 9ffd849979688997a60c50584e8f43cdb5183c09
5
5
  SHA512:
6
- metadata.gz: 3a5f907888b451e93666d8335406e37dce3ea8e286b6282a9300b9eb27a1bd3cff6869f68480e305204f79e0cb1a45ce936d6987b18d183236999aa184c5dfc9
7
- data.tar.gz: c3324384ef24aa90905b8d4eb8f5cc0fd4baa710eb3b51d20bcc7a7d81f0cc33d16f0ba4ed269beb877d9046014593c9733d6ebc79bc1eb2148e0d9704026594
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=<%= port %><% engine.env.each_pair do |var,env| %>
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] %>
@@ -1,3 +1,2 @@
1
1
  [Unit]
2
2
  PartOf=<%= app %>.target
3
- Wants=<%= process_names.join(' ') %>
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 :concurrency, :type => :string, :aliases => "-c", :banner => '"alpha=5,bar=3"', :desc => 'Specify what processes will run and how many. Default: "all=1"'
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!
@@ -27,7 +27,7 @@ class Foreman::Engine
27
27
  def initialize(options={})
28
28
  @options = options.dup
29
29
 
30
- @options[:formation] ||= (options[:concurrency] || "all=1")
30
+ @options[:formation] ||= "all=1"
31
31
  @options[:timeout] ||= 5
32
32
 
33
33
  @env = {}
@@ -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"].concat(Dir["#{location}/#{app}*.service"]).each do |file|
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
- next if engine.formation[name] < 1
17
-
18
- process_names = []
19
-
20
- 1.upto(engine.formation[name]) do |num|
21
- port = engine.port_for(process, num)
22
- write_template "systemd/process.service.erb", "#{app}-#{name}-#{num}.service", binding
23
- process_names << "#{app}-#{name}-#{num}.service"
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
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.81.0"
3
+ VERSION = "0.82.0"
4
4
 
5
5
  end
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.81.0" "Foreman Manual"
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/standard/app.target"))
20
- expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/standard/app-alpha.target"))
21
- expect(File.read("/tmp/init/app-alpha-1.service")).to eq(example_export_file("systemd/standard/app-alpha-1.service"))
22
- expect(File.read("/tmp/init/app-bravo.target")).to eq(example_export_file("systemd/standard/app-bravo.target"))
23
- expect(File.read("/tmp/init/app-bravo-1.service")).to eq(example_export_file("systemd/standard/app-bravo-1.service"))
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-1.service")
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-1.service")
32
- mock(FileUtils).rm("/tmp/init/app-foo-bar.target")
33
- mock(FileUtils).rm("/tmp/init/app-foo-bar-1.service")
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-1.service")
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-1.service")).to match(/KEY=some "value"$/)
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/concurrency/app.target"))
54
- expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/concurrency/app-alpha.target"))
55
- expect(File.read("/tmp/init/app-alpha-1.service")).to eq(example_export_file("systemd/concurrency/app-alpha-1.service"))
56
- expect(File.read("/tmp/init/app-alpha-2.service")).to eq(example_export_file("systemd/concurrency/app-alpha-2.service"))
57
- expect(File.exists?("/tmp/init/app-bravo-1.service")).to eq(false)
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
 
@@ -0,0 +1,2 @@
1
+ [Unit]
2
+ PartOf=app.target
@@ -4,7 +4,7 @@ PartOf=app-alpha.target
4
4
  [Service]
5
5
  User=app
6
6
  WorkingDirectory=/tmp/app
7
- Environment=PORT=5000
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
@@ -0,0 +1,2 @@
1
+ [Unit]
2
+ PartOf=app.target
@@ -4,7 +4,7 @@ PartOf=app-bravo.target
4
4
  [Service]
5
5
  User=app
6
6
  WorkingDirectory=/tmp/app
7
- Environment=PORT=5100
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
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.81.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-04-26 00:00:00.000000000 Z
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/concurrency/app-alpha-1.service
125
- - spec/resources/export/systemd/concurrency/app-alpha-2.service
126
- - spec/resources/export/systemd/concurrency/app-alpha.target
127
- - spec/resources/export/systemd/concurrency/app.target
128
- - spec/resources/export/systemd/standard/app-alpha-1.service
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,3 +0,0 @@
1
- [Unit]
2
- PartOf=app.target
3
- Wants=app-alpha-1.service app-alpha-2.service
@@ -1,5 +0,0 @@
1
- [Unit]
2
- Wants=app-alpha.target
3
-
4
- [Install]
5
- WantedBy=multi-user.target
@@ -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
@@ -1,3 +0,0 @@
1
- [Unit]
2
- PartOf=app.target
3
- Wants=app-alpha-1.service
@@ -1,3 +0,0 @@
1
- [Unit]
2
- PartOf=app.target
3
- Wants=app-bravo-1.service