config_o_mat 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: b780a147a3eed4c14e90e0905d9002a1810916bb10ba7cf8e18468044a291809
4
- data.tar.gz: 87c03b8c3ff63239e4c24efb30c118b8ac3e6abfba8c38c4193037eb50bd6854
3
+ metadata.gz: 35eaeccb6abdf69afb14c8cbe951c4579734f27af4844673b1761db70dfd1bf1
4
+ data.tar.gz: 392a61b3ee55ba8d9351c2b7d69d39de7d591bbde87f3374fac77fc425e628b8
5
5
  SHA512:
6
- metadata.gz: e4f55821c2ff2fdc1bd701d5448d87d7f7a7cd168a04811395d3ffdbfff49ca4b25689567c21905fc597427e3993f3b79ee213b4add27961def2832d7f98b475
7
- data.tar.gz: e083e171bcea253ad814d53ba6ff713f4460cf60391e367a92a9dec620b7daea3633e976d5b9f4a0ae674023f35acc768f3598ac4c9f57d1b71615d63b03ef43
6
+ metadata.gz: 31f9277ada3b1a7fc09efe007a3b530fb3f100c480c09ab0af83a9879ab1fa3ea0b0db3252300fe8dbe9bb9877acf2244727a94554a6384bf52641a5a95c685b
7
+ data.tar.gz: 4346bae4957800e67e238c0231ddf1b424e1c5afe60a86e2d29e2134f480d56979d320514e24b412557f7f31b239fd7342ffdce459c387ba2b3ce56ce3e3e054
@@ -41,13 +41,11 @@ module ConfigOMat
41
41
  private
42
42
 
43
43
  def do_restart(service, service_def)
44
- unit = service_def.systemd_unit
45
-
46
- file_path = File.join(runtime_directory, unit + '.restart')
44
+ file_path = File.join(runtime_directory, service_def.restart_unit + '.restart')
47
45
 
48
46
  logger&.notice(
49
47
  :service_restart,
50
- name: service, systemd_unit: unit, touched_path: file_path
48
+ name: service, systemd_unit: service_def.systemd_unit, touched_path: file_path
51
49
  )
52
50
 
53
51
  FileUtils.touch(file_path)
@@ -27,10 +27,10 @@ module ConfigOMat
27
27
 
28
28
  def call
29
29
  grouped_restart_modes = service_defs.values.group_by(&:restart_mode)
30
- restarts = grouped_restart_modes[:restart]
30
+ restarts = grouped_restart_modes.fetch(:restart, []) + grouped_restart_modes.fetch(:restart_all, [])
31
31
  flip_flops = grouped_restart_modes[:flip_flop]
32
32
 
33
- enable_restarts(restarts) if restarts
33
+ enable_restarts(restarts) if !restarts.empty?
34
34
  enable_flip_flops(flip_flops) if flip_flops
35
35
 
36
36
  systemd_interface.daemon_reload
@@ -54,10 +54,9 @@ module ConfigOMat
54
54
  def enable_restarts(services)
55
55
  units = []
56
56
  services.each do |service|
57
- unit = service.systemd_unit
58
- units << unit
57
+ units << service.restart_unit
59
58
 
60
- write_dropin(unit, service)
59
+ write_dropin(service.systemd_unit, service)
61
60
  end
62
61
 
63
62
  systemd_interface.enable_restart_paths(units)
@@ -87,23 +87,21 @@ module ConfigOMat
87
87
  class Service < ConfigItem
88
88
  RESTART_MODES = %i[restart flip_flop restart_all].freeze
89
89
 
90
- attr_reader :systemd_unit, :restart_mode, :templates
90
+ attr_reader :systemd_unit, :restart_mode, :templates, :restart_unit
91
91
 
92
92
  def initialize(opts)
93
93
  @systemd_unit = (opts[:systemd_unit] || '')
94
94
  @restart_mode = opts[:restart_mode]&.to_sym
95
95
  @templates = opts[:templates]
96
96
 
97
- if @restart_mode == :flip_flop && !@systemd_unit.include?('@')
97
+ if (@restart_mode == :flip_flop || @restart_mode == :restart_all) && !@systemd_unit.include?('@')
98
98
  @systemd_unit = "#{@systemd_unit}@"
99
- elsif @restart_mode == :restart_all
100
- if @systemd_unit.include?('@')
101
- if !@systemd_unit.end_with?('\\x2a')
102
- @systemd_unit = "#{@systemd_unit}\\x2a"
103
- end
104
- else
105
- @systemd_unit = "#{@systemd_unit}@\\x2a"
106
- end
99
+ end
100
+
101
+ @restart_unit = @systemd_unit
102
+
103
+ if @restart_mode == :restart_all
104
+ @restart_unit = "#{@restart_unit}\\x2a"
107
105
  end
108
106
  end
109
107
 
@@ -123,7 +121,7 @@ module ConfigOMat
123
121
  error :systemd_unit, 'must not be a naked instantiated unit when restart_mode=restart'
124
122
  end
125
123
 
126
- if restart_mode == :restart_all && !@systemd_unit.end_with?('@\\x2a')
124
+ if restart_mode == :restart_all && !@systemd_unit.end_with?('@')
127
125
  error :systemd_unit, 'must not be an instantiated unit when restart_mode=restart_all'
128
126
  end
129
127
  end
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module ConfigOMat
18
- VERSION = "0.2.0"
18
+ VERSION = "0.2.1"
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_o_mat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Scarborough