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 +4 -4
- data/lib/foreman_debian.rb +3 -0
- data/lib/foreman_debian/engine.rb +7 -4
- data/lib/foreman_debian/engine_helper.rb +13 -6
- data/lib/foreman_debian/initd/engine.rb +8 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d6aa19d3ebbd8fe3265eb96870fd7002682c037
|
4
|
+
data.tar.gz: 2b2ae19872ecea10da5154d4f8b686116b2daa9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a83b6b90a4d5728e691e593ee367fc51d24f0d16310d8128340fb82f1d2309bbde0cd8024b67ac151adb2c0bf21ae14458da176032641edba76ea40055a1ad7
|
7
|
+
data.tar.gz: 2b9ea9fd8c3354e4548ddb3255ffd5385b90ffbc7c61a1409300a7a08c2279f5ba5cb91d5fd8a287bc3912ca96d8d4740ea6db1e00e8c7d8f146a64f6a415500
|
data/lib/foreman_debian.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
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
|
-
|
44
|
-
|
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 "
|
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 "
|
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
|
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:
|
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:
|
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:
|
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.
|
128
|
+
rubygems_version: 2.2.2
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Foreman wrapper for debian
|