foreman-export-initd 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/foreman-export-initd.rb +3 -2
- data/lib/foreman/export/initd.rb +8 -25
- data/lib/foreman/export/initd_monit.rb +6 -24
- data/lib/initd/export.rb +36 -0
- data/lib/initd/script.rb +2 -2
- data/templates/monit_config.erb +1 -1
- data/templates/script.erb +7 -8
- metadata +4 -19
- data/bin/foreman-initd +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dee0c30fbc1a2ab4e63333ac1c0fb6a3da43990b
|
4
|
+
data.tar.gz: 885e3be0f73c0d93ad3fbfcceaf012f979a6862c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08abc5542da2835c7682d678ac1eedee0646e2781407ab736ab252ec2c3a61cb61d49c62b6e2c431d81d86110763e946da065d1f9305d6df504c4806d7b6491b
|
7
|
+
data.tar.gz: 8e0d70cee0d439db9c4dd63e954555374f3d9d55e2b7c80097d35371fb33dc5e558364587ee9138427b8a21366b7534d80a59cb32b10de83f1e2eccc45ab63ff
|
data/README.md
CHANGED
data/lib/foreman-export-initd.rb
CHANGED
@@ -5,8 +5,9 @@ module Initd
|
|
5
5
|
require 'shellwords'
|
6
6
|
require 'foreman/export'
|
7
7
|
require 'foreman/cli'
|
8
|
-
require 'foreman/export/initd'
|
9
|
-
require 'foreman/export/initd_monit'
|
10
8
|
require 'initd/script'
|
11
9
|
require 'initd/monit_config'
|
10
|
+
require 'initd/export'
|
11
|
+
require 'foreman/export/initd'
|
12
|
+
require 'foreman/export/initd_monit'
|
12
13
|
end
|
data/lib/foreman/export/initd.rb
CHANGED
@@ -1,40 +1,23 @@
|
|
1
1
|
require 'foreman-export-initd'
|
2
2
|
|
3
3
|
class Foreman::Export::Initd < Foreman::Export::Base
|
4
|
+
include Initd::Export
|
4
5
|
|
5
6
|
def export
|
6
7
|
error('Must specify a location') unless location
|
8
|
+
setup
|
7
9
|
|
8
|
-
cwd = Pathname.new(engine.root)
|
9
|
-
export_path = Pathname.new(location)
|
10
|
-
say "creating: #{export_path}"
|
11
|
-
FileUtils.mkdir_p(export_path)
|
12
|
-
|
13
|
-
existing = []
|
14
|
-
Dir.glob export_path.join("#{app}-*") do |filename|
|
15
|
-
contents = File.new(filename, 'r').read
|
16
|
-
existing.push(filename) if contents.match(/# Autogenerated by foreman/)
|
17
|
-
end
|
18
|
-
|
19
|
-
exported = []
|
20
10
|
engine.each_process do |name, process|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
concurrency =
|
11
|
+
args = Shellwords.split(process.command)
|
12
|
+
script = Pathname.new(engine.root).join(args.shift)
|
13
|
+
path = path(name)
|
14
|
+
concurrency = concurrency(name)
|
25
15
|
if concurrency > 0
|
26
16
|
say 'Warning: Initd exporter ignores concurrency > 1' if concurrency > 1
|
27
17
|
contents = Initd::Script.new(path, script, args, user).content
|
28
|
-
|
29
|
-
File.chmod(0755, path)
|
30
|
-
exported.push path.to_s
|
18
|
+
export_file path, contents
|
31
19
|
end
|
32
20
|
end
|
33
|
-
|
34
|
-
to_remove = existing - exported
|
35
|
-
to_remove.each do |filename|
|
36
|
-
say 'removing ' + filename
|
37
|
-
File.unlink filename
|
38
|
-
end
|
21
|
+
cleanup
|
39
22
|
end
|
40
23
|
end
|
@@ -1,38 +1,20 @@
|
|
1
1
|
require 'foreman-export-initd'
|
2
2
|
|
3
3
|
class Foreman::Export::InitdMonit < Foreman::Export::Base
|
4
|
+
include Initd::Export
|
4
5
|
|
5
6
|
def export
|
6
7
|
error('Must specify a location') unless location
|
7
|
-
|
8
|
-
cwd = Pathname.new(engine.root)
|
9
|
-
export_path = Pathname.new(location)
|
10
|
-
say "creating: #{export_path}"
|
11
|
-
FileUtils.mkdir_p(export_path)
|
12
|
-
|
13
|
-
existing = []
|
14
|
-
Dir.glob export_path.join("#{app}-*") do |filename|
|
15
|
-
contents = File.new(filename, 'r').read
|
16
|
-
existing.push(filename) if contents.match(/# Autogenerated by foreman/)
|
17
|
-
end
|
18
|
-
|
19
|
-
exported = []
|
8
|
+
setup
|
20
9
|
engine.each_process do |name, process|
|
21
|
-
|
22
|
-
|
10
|
+
concurrency = concurrency name
|
11
|
+
path = path name
|
23
12
|
if concurrency > 0
|
24
13
|
say 'Warning: Initd exporter ignores concurrency > 1' if concurrency > 1
|
25
14
|
contents = Initd::MonitConfig.new(app, path).content
|
26
|
-
|
27
|
-
File.chmod(0755, path)
|
28
|
-
exported.push path.to_s
|
15
|
+
export_file path, contents
|
29
16
|
end
|
30
17
|
end
|
31
|
-
|
32
|
-
to_remove = existing - exported
|
33
|
-
to_remove.each do |filename|
|
34
|
-
say 'removing ' + filename
|
35
|
-
File.unlink filename
|
36
|
-
end
|
18
|
+
cleanup
|
37
19
|
end
|
38
20
|
end
|
data/lib/initd/export.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Initd::Export
|
2
|
+
|
3
|
+
def export_path
|
4
|
+
Pathname.new location
|
5
|
+
end
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@exported = []
|
9
|
+
say "creating: #{export_path}"
|
10
|
+
FileUtils.mkdir_p(export_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def cleanup
|
14
|
+
Dir.glob export_path.join("#{app}-*") do |filename|
|
15
|
+
contents = File.new(filename, 'r').read
|
16
|
+
next unless contents.match(/# Autogenerated by foreman/)
|
17
|
+
next if @exported.include? filename.to_s
|
18
|
+
say 'removing ' + filename
|
19
|
+
File.unlink filename
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def export_file (path, contents)
|
24
|
+
write_file(path, contents)
|
25
|
+
File.chmod(0755, path)
|
26
|
+
@exported.push path.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def concurrency(name)
|
30
|
+
engine.formation[name]
|
31
|
+
end
|
32
|
+
|
33
|
+
def path(name)
|
34
|
+
export_path.join("#{app}-#{name}")
|
35
|
+
end
|
36
|
+
end
|
data/lib/initd/script.rb
CHANGED
@@ -11,14 +11,14 @@ class Initd::Script
|
|
11
11
|
@daemon = {
|
12
12
|
:name => name,
|
13
13
|
:script => script,
|
14
|
-
:args => args
|
14
|
+
:args => args,
|
15
15
|
:user => user,
|
16
16
|
}
|
17
17
|
@description = name
|
18
18
|
end
|
19
19
|
|
20
20
|
def name
|
21
|
-
path.basename.to_s
|
21
|
+
@path.basename.to_s
|
22
22
|
end
|
23
23
|
|
24
24
|
def pidfile
|
data/templates/monit_config.erb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated by foreman
|
2
|
-
check process <%= name %> with pidfile <%= pidfile %>
|
2
|
+
check process <%= name.shellescape %> with pidfile <%= pidfile.to_s.shellescape %>
|
3
3
|
group <%= app %>
|
4
4
|
start program = "/etc/init.d/<%= name %> start"
|
5
5
|
stop program = "/etc/init.d/<%= name %> stop"
|
data/templates/script.erb
CHANGED
@@ -12,13 +12,12 @@
|
|
12
12
|
# Description: <%= description %>
|
13
13
|
### END INIT INFO
|
14
14
|
|
15
|
-
NAME=<%= name %>
|
16
|
-
DESC=<%= description %>
|
17
|
-
DAEMON=<%= daemon[:script] %>
|
18
|
-
DAEMON_USER=<%= daemon[:user] %>
|
19
|
-
PIDDIR=<%= pidfile.dirname %>
|
20
|
-
PIDFILE=<%= pidfile %>
|
21
|
-
DAEMON_ARGS=<%= daemon[:args].shellescape %>
|
15
|
+
NAME=<%= Shellwords.escape name %>
|
16
|
+
DESC=<%= Shellwords.escape description %>
|
17
|
+
DAEMON=<%= Shellwords.escape daemon[:script].to_s %>
|
18
|
+
DAEMON_USER=<%= Shellwords.escape daemon[:user] %>
|
19
|
+
PIDDIR=<%= Shellwords.escape pidfile.dirname.to_s %>
|
20
|
+
PIDFILE=<%= Shellwords.escape pidfile.to_s %>
|
22
21
|
|
23
22
|
test -x ${DAEMON} || exit 0
|
24
23
|
set -e
|
@@ -29,7 +28,7 @@ case "${1}" in
|
|
29
28
|
start)
|
30
29
|
log_daemon_msg "Starting ${DESC}" "${NAME}"
|
31
30
|
mkdir -p ${PIDDIR}
|
32
|
-
if (start-stop-daemon --start --make-pidfile --background --pidfile $PIDFILE --chuid $DAEMON_USER --exec $DAEMON --
|
31
|
+
if (start-stop-daemon --start --make-pidfile --background --pidfile $PIDFILE --chuid $DAEMON_USER --exec $DAEMON -- <%= Shellwords.join daemon[:args] %>); then
|
33
32
|
log_end_msg 0
|
34
33
|
else
|
35
34
|
log_end_msg 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-export-initd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Durka
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: foreman
|
@@ -53,20 +53,6 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '2.0'
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: rake
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.4.3
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.4.3
|
70
56
|
- !ruby/object:Gem::Dependency
|
71
57
|
name: fakefs
|
72
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,16 +69,15 @@ dependencies:
|
|
83
69
|
version: 0.4.3
|
84
70
|
description: init.d export scripts for foreman
|
85
71
|
email: tomasz@durka.pl
|
86
|
-
executables:
|
87
|
-
- foreman-initd
|
72
|
+
executables: []
|
88
73
|
extensions: []
|
89
74
|
extra_rdoc_files:
|
90
75
|
- README.md
|
91
76
|
files:
|
92
|
-
- bin/foreman-initd
|
93
77
|
- lib/foreman/export/initd.rb
|
94
78
|
- lib/foreman/export/initd_monit.rb
|
95
79
|
- lib/foreman-export-initd.rb
|
80
|
+
- lib/initd/export.rb
|
96
81
|
- lib/initd/monit_config.rb
|
97
82
|
- lib/initd/script.rb
|
98
83
|
- templates/monit_config.erb
|