foreman 0.85.0 → 0.87.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/data/export/systemd/master.target.erb +1 -1
  4. data/data/export/systemd/process.service.erb +6 -3
  5. data/lib/foreman/cli.rb +3 -3
  6. data/lib/foreman/export/systemd.rb +7 -13
  7. data/lib/foreman/vendor/thor/lib/thor/actions/create_file.rb +103 -0
  8. data/lib/foreman/vendor/thor/lib/thor/actions/create_link.rb +59 -0
  9. data/lib/foreman/vendor/thor/lib/thor/actions/directory.rb +118 -0
  10. data/lib/foreman/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
  11. data/lib/foreman/vendor/thor/lib/thor/actions/file_manipulation.rb +327 -0
  12. data/lib/foreman/vendor/thor/lib/thor/actions/inject_into_file.rb +103 -0
  13. data/lib/foreman/vendor/thor/lib/thor/actions.rb +318 -0
  14. data/lib/foreman/vendor/thor/lib/thor/base.rb +656 -0
  15. data/lib/foreman/vendor/thor/lib/thor/command.rb +133 -0
  16. data/lib/foreman/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +85 -0
  17. data/lib/foreman/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
  18. data/lib/foreman/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
  19. data/lib/foreman/vendor/thor/lib/thor/error.rb +32 -0
  20. data/lib/foreman/vendor/thor/lib/thor/group.rb +281 -0
  21. data/lib/foreman/vendor/thor/lib/thor/invocation.rb +177 -0
  22. data/lib/foreman/vendor/thor/lib/thor/line_editor/basic.rb +35 -0
  23. data/lib/foreman/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  24. data/lib/foreman/vendor/thor/lib/thor/line_editor.rb +17 -0
  25. data/lib/foreman/vendor/thor/lib/thor/parser/argument.rb +70 -0
  26. data/lib/foreman/vendor/thor/lib/thor/parser/arguments.rb +175 -0
  27. data/lib/foreman/vendor/thor/lib/thor/parser/option.rb +146 -0
  28. data/lib/foreman/vendor/thor/lib/thor/parser/options.rb +220 -0
  29. data/lib/foreman/vendor/thor/lib/thor/parser.rb +4 -0
  30. data/lib/foreman/vendor/thor/lib/thor/rake_compat.rb +71 -0
  31. data/lib/foreman/vendor/thor/lib/thor/runner.rb +322 -0
  32. data/lib/foreman/vendor/thor/lib/thor/shell/basic.rb +436 -0
  33. data/lib/foreman/vendor/thor/lib/thor/shell/color.rb +149 -0
  34. data/lib/foreman/vendor/thor/lib/thor/shell/html.rb +126 -0
  35. data/lib/foreman/vendor/thor/lib/thor/shell.rb +81 -0
  36. data/lib/foreman/vendor/thor/lib/thor/util.rb +268 -0
  37. data/lib/foreman/vendor/thor/lib/thor/version.rb +3 -0
  38. data/lib/foreman/vendor/thor/lib/thor.rb +492 -0
  39. data/lib/foreman/version.rb +1 -1
  40. data/man/foreman.1 +1 -1
  41. data/spec/foreman/export/systemd_spec.rb +88 -46
  42. data/spec/resources/export/systemd/{app-alpha@.service → app-alpha.1.service} +6 -3
  43. data/spec/resources/export/systemd/{app-bravo@.service → app-alpha.2.service} +6 -3
  44. data/spec/resources/export/systemd/app-bravo.1.service +18 -0
  45. data/spec/resources/export/systemd/app.target +1 -1
  46. data/spec/spec_helper.rb +1 -1
  47. metadata +39 -22
  48. data/data/export/systemd/process_master.target.erb +0 -2
@@ -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 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
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
- it "cleans up if exporting into an existing dir" do
30
- expect(FileUtils).to receive(:rm).with("/tmp/init/app.target")
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
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-alpha@.service")
33
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-alpha.target")
34
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-alpha.target.wants/app-alpha@5000.service")
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
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-bravo.target")
38
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-bravo@.service")
39
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-bravo.target.wants/app-bravo@5100.service")
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
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo_bar.target")
43
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo_bar@.service")
44
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo_bar.target.wants/app-foo_bar@5200.service")
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
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo-bar.target")
48
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo-bar@.service")
49
- expect(FileUtils).to receive(:rm).with("/tmp/init/app-foo-bar.target.wants/app-foo-bar@5300.service")
50
- expect(FileUtils).to receive(:rm_r).with("/tmp/init/app-foo-bar.target.wants")
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
- systemd.export
54
- systemd.export
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@.service")).to match(/KEY=some "value"/)
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@.service")).to match(/^ExecStart=/)
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 to the filesystem with concurrency" do
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 eq(example_export_file("systemd/app.target"))
76
- expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/app-alpha.target"))
77
- expect(File.read("/tmp/init/app-alpha@.service")).to eq(example_export_file("systemd/app-alpha@.service"))
78
- expect(File.read("/tmp/init/app-bravo.target")).to eq(example_export_file("systemd/app-bravo.target"))
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 templates" do
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 "can export with alternate template files" do
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
- context "with alternate templates from home dir" do
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 "default_alternate_template"
146
+ file.puts "home_dir_template"
104
147
  end
105
148
  end
106
149
 
107
- it "can export with alternate template files" do
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("default_alternate_template\n")
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-alpha.target
2
+ PartOf=app.target
3
+ StopWhenUnneeded=yes
3
4
 
4
5
  [Service]
5
6
  User=app
6
7
  WorkingDirectory=/tmp/app
7
- Environment=PORT=%i
8
- ExecStart=/bin/bash -lc 'exec ./alpha'
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-bravo.target
2
+ PartOf=app.target
3
+ StopWhenUnneeded=yes
3
4
 
4
5
  [Service]
5
6
  User=app
6
7
  WorkingDirectory=/tmp/app
7
- Environment=PORT=%i
8
- ExecStart=/bin/bash -lc 'exec ./bravo'
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
@@ -1,5 +1,5 @@
1
1
  [Unit]
2
- Wants=app-alpha.target app-bravo.target app-foo_bar.target app-foo-bar.target
2
+ Wants=app-alpha.1.service app-bravo.1.service app-foo_bar.1.service app-foo-bar.1.service
3
3
 
4
4
  [Install]
5
5
  WantedBy=multi-user.target
data/spec/spec_helper.rb CHANGED
@@ -105,7 +105,7 @@ end
105
105
  def write_file(file)
106
106
  FileUtils.mkdir_p(File.dirname(file))
107
107
  File.open(file, 'w') do |f|
108
- yield(f)
108
+ yield(f) if block_given?
109
109
  end
110
110
  end
111
111
 
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.85.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: 2018-06-18 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: thor
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.19.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.19.1
11
+ date: 2020-01-07 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Process manager for applications with multiple components
28
14
  email: ddollar@gmail.com
29
15
  executables:
@@ -52,7 +38,6 @@ files:
52
38
  - data/export/supervisord/app.conf.erb
53
39
  - data/export/systemd/master.target.erb
54
40
  - data/export/systemd/process.service.erb
55
- - data/export/systemd/process_master.target.erb
56
41
  - data/export/upstart/master.conf.erb
57
42
  - data/export/upstart/process.conf.erb
58
43
  - data/export/upstart/process_master.conf.erb
@@ -75,6 +60,38 @@ files:
75
60
  - lib/foreman/helpers.rb
76
61
  - lib/foreman/process.rb
77
62
  - lib/foreman/procfile.rb
63
+ - lib/foreman/vendor/thor/lib/thor.rb
64
+ - lib/foreman/vendor/thor/lib/thor/actions.rb
65
+ - lib/foreman/vendor/thor/lib/thor/actions/create_file.rb
66
+ - lib/foreman/vendor/thor/lib/thor/actions/create_link.rb
67
+ - lib/foreman/vendor/thor/lib/thor/actions/directory.rb
68
+ - lib/foreman/vendor/thor/lib/thor/actions/empty_directory.rb
69
+ - lib/foreman/vendor/thor/lib/thor/actions/file_manipulation.rb
70
+ - lib/foreman/vendor/thor/lib/thor/actions/inject_into_file.rb
71
+ - lib/foreman/vendor/thor/lib/thor/base.rb
72
+ - lib/foreman/vendor/thor/lib/thor/command.rb
73
+ - lib/foreman/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
74
+ - lib/foreman/vendor/thor/lib/thor/core_ext/io_binary_read.rb
75
+ - lib/foreman/vendor/thor/lib/thor/core_ext/ordered_hash.rb
76
+ - lib/foreman/vendor/thor/lib/thor/error.rb
77
+ - lib/foreman/vendor/thor/lib/thor/group.rb
78
+ - lib/foreman/vendor/thor/lib/thor/invocation.rb
79
+ - lib/foreman/vendor/thor/lib/thor/line_editor.rb
80
+ - lib/foreman/vendor/thor/lib/thor/line_editor/basic.rb
81
+ - lib/foreman/vendor/thor/lib/thor/line_editor/readline.rb
82
+ - lib/foreman/vendor/thor/lib/thor/parser.rb
83
+ - lib/foreman/vendor/thor/lib/thor/parser/argument.rb
84
+ - lib/foreman/vendor/thor/lib/thor/parser/arguments.rb
85
+ - lib/foreman/vendor/thor/lib/thor/parser/option.rb
86
+ - lib/foreman/vendor/thor/lib/thor/parser/options.rb
87
+ - lib/foreman/vendor/thor/lib/thor/rake_compat.rb
88
+ - lib/foreman/vendor/thor/lib/thor/runner.rb
89
+ - lib/foreman/vendor/thor/lib/thor/shell.rb
90
+ - lib/foreman/vendor/thor/lib/thor/shell/basic.rb
91
+ - lib/foreman/vendor/thor/lib/thor/shell/color.rb
92
+ - lib/foreman/vendor/thor/lib/thor/shell/html.rb
93
+ - lib/foreman/vendor/thor/lib/thor/util.rb
94
+ - lib/foreman/vendor/thor/lib/thor/version.rb
78
95
  - lib/foreman/version.rb
79
96
  - man/foreman.1
80
97
  - spec/foreman/cli_spec.rb
@@ -121,10 +138,11 @@ files:
121
138
  - spec/resources/export/runit/app-bravo-1/run
122
139
  - spec/resources/export/supervisord/app-alpha-1.conf
123
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
124
143
  - spec/resources/export/systemd/app-alpha.target
125
- - spec/resources/export/systemd/app-alpha@.service
144
+ - spec/resources/export/systemd/app-bravo.1.service
126
145
  - spec/resources/export/systemd/app-bravo.target
127
- - spec/resources/export/systemd/app-bravo@.service
128
146
  - spec/resources/export/systemd/app.target
129
147
  - spec/resources/export/upstart/app-alpha-1.conf
130
148
  - spec/resources/export/upstart/app-alpha-2.conf
@@ -152,8 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
170
  - !ruby/object:Gem::Version
153
171
  version: '0'
154
172
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.7.3
173
+ rubygems_version: 3.0.3
157
174
  signing_key:
158
175
  specification_version: 4
159
176
  summary: Process manager for applications with multiple components
@@ -1,2 +0,0 @@
1
- [Unit]
2
- PartOf=<%= app %>.target