foreman_debian 0.0.13 → 0.1.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: 0db6d638cba341f0f659141b593102b37744c65a
4
- data.tar.gz: d4d26d93e22a15d5425a7785cc35a136a3dd0335
3
+ metadata.gz: 5d6aa19d3ebbd8fe3265eb96870fd7002682c037
4
+ data.tar.gz: 2b2ae19872ecea10da5154d4f8b686116b2daa9c
5
5
  SHA512:
6
- metadata.gz: be7a422c35826170588bc9684c7f49915a9c7d6230e5bea3a959796844c7d1afaff9a642463ea0b9b8fb94f0b82854a84ec34f0cf5799254e4e1ea82bc1067f1
7
- data.tar.gz: 1517b9442e2be8ed2aba884d3615a728c4ca01b564521346608f83c07c8d962c204fda628ad856e26d72ea9d5aa2dde7e05273d91a40b7b64851beabfa2e5e8d
6
+ metadata.gz: 7a83b6b90a4d5728e691e593ee367fc51d24f0d16310d8128340fb82f1d2309bbde0cd8024b67ac151adb2c0bf21ae14458da176032641edba76ea40055a1ad7
7
+ data.tar.gz: 2b9ea9fd8c3354e4548ddb3255ffd5385b90ffbc7c61a1409300a7a08c2279f5ba5cb91d5fd8a287bc3912ca96d8d4740ea6db1e00e8c7d8f146a64f6a415500
@@ -9,6 +9,7 @@ module ForemanDebian
9
9
  require 'fileutils'
10
10
  require 'logger'
11
11
  require 'open3'
12
+ require 'thwait'
12
13
  require 'foreman_debian/template'
13
14
  require 'foreman_debian/engine'
14
15
  require 'foreman_debian/engine_helper'
@@ -29,4 +30,6 @@ module ForemanDebian
29
30
  def self.logger=(logger)
30
31
  @logger = logger
31
32
  end
33
+
34
+ Thread.abort_on_exception = true
32
35
  end
@@ -6,21 +6,24 @@ module ForemanDebian
6
6
  end
7
7
 
8
8
  def install(jobs, concurrency, user)
9
+ threads = []
9
10
  initd_engine = Initd::Engine.new(@app)
10
11
  monit_engine = Monit::Engine.new(@app)
11
12
  jobs.each do |name, command|
12
13
  if job_concurrency(concurrency, name) > 0
13
- script = initd_engine.create_script(name, command, user)
14
- initd_engine.install(script)
15
- monit_engine.install(name, script)
14
+ threads << Thread.new do
15
+ script = initd_engine.create_script(name, command, user)
16
+ initd_engine.install(script)
17
+ monit_engine.install(name, script)
18
+ end
16
19
  end
17
20
  end
21
+ ThreadsWait.all_waits(*threads)
18
22
  initd_engine.cleanup
19
23
  monit_engine.cleanup
20
24
  end
21
25
 
22
26
  def uninstall
23
- stop
24
27
  Initd::Engine.new(@app).cleanup
25
28
  Monit::Engine.new(@app).cleanup
26
29
  end
@@ -12,10 +12,12 @@ module ForemanDebian
12
12
  end
13
13
 
14
14
  def cleanup
15
+ threads = []
15
16
  each_file do |path|
16
17
  next if @exported.include? path
17
- remove_file path
18
+ threads << Thread.new { remove_file path }
18
19
  end
20
+ ThreadsWait.all_waits(*threads)
19
21
  end
20
22
 
21
23
  def export_file(path)
@@ -28,10 +30,15 @@ module ForemanDebian
28
30
  @output.info " remove #{path.to_s}"
29
31
  end
30
32
 
33
+ def get_files
34
+ paths = Pathname.glob(@export_path.join("#{@app}-*"))
35
+ paths.select do |path|
36
+ path.read.match(/# Autogenerated by foreman/)
37
+ end
38
+ end
39
+
31
40
  def each_file(&block)
32
- Dir.glob @export_path.join("#{@app}-*") do |path|
33
- path = Pathname.new(path)
34
- next unless path.read.match(/# Autogenerated by foreman/)
41
+ get_files.each do |path|
35
42
  block.call(path)
36
43
  end
37
44
  end
@@ -40,8 +47,8 @@ module ForemanDebian
40
47
  Open3.popen3(command) do |i, o, e, w|
41
48
  i.close
42
49
  out, err, wait = o.read, e.read, w
43
- s = wait ? wait.value : $?
44
- s.success? or raise "Command `#{command}` failed: #{err}"
50
+ status = wait ? wait.value : $?
51
+ raise "Command `#{command}` failed: #{err}" unless status.success?
45
52
  out
46
53
  end
47
54
  end
@@ -30,26 +30,30 @@ module ForemanDebian
30
30
  end
31
31
 
32
32
  def start
33
+ threads = []
33
34
  each_file do |path|
34
- start_file(path)
35
+ threads << Thread.new { start_file(path) }
35
36
  end
37
+ ThreadsWait.all_waits(*threads)
36
38
  end
37
39
 
38
40
  def stop
41
+ threads = []
39
42
  each_file do |path|
40
- stop_file(path)
43
+ threads << Thread.new { stop_file(path) }
41
44
  end
45
+ ThreadsWait.all_waits(*threads)
42
46
  end
43
47
 
44
48
  def start_file(path)
45
49
  exec_command("#{path.to_s} start")
46
- @output.info " start #{path.to_s}"
50
+ @output.info " start #{path.to_s}"
47
51
  exec_command("update-rc.d #{path.basename} defaults") if path.dirname.eql? @system_export_path
48
52
  end
49
53
 
50
54
  def stop_file(path)
51
55
  exec_command("#{path.to_s} stop")
52
- @output.info " stop #{path.to_s}"
56
+ @output.info " stop #{path.to_s}"
53
57
  exec_command("update-rc.d -f #{path.basename} remove") if path.dirname.eql? @system_export_path
54
58
  end
55
59
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_debian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - cargomedia
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-14 00:00:00.000000000 Z
12
+ date: 2015-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.4'
76
+ version: 0.5.2
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '0.4'
83
+ version: 0.5.2
84
84
  description: Wrapper around foreman and Procfile concept. It implements basic exporting,
85
85
  installing and uninstalling of initd scripts and monit configs for debian.
86
86
  email: hello@cargomedia.ch
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.4.2
128
+ rubygems_version: 2.2.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Foreman wrapper for debian