pleaserun 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.asciidoc +7 -0
- data/Gemfile.lock +1 -1
- data/lib/pleaserun/detector.rb +12 -10
- data/lib/pleaserun/platform/systemd.rb +11 -2
- data/pleaserun.gemspec +1 -1
- data/spec/pleaserun/platform/systemd_spec.rb +4 -2
- data/templates/systemd/default/program.service +1 -1
- data/templates/sysv/lsb-3.1/init.sh +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e0519711adf2648e38698c8e3aca1b736f4c4e
|
4
|
+
data.tar.gz: 8ea0617089d0b51121baffb1afe909f223b56ce3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4161d65cabbb8f8668e2a3a088b76c25533bb5efe98350b81b5582d22f6fbd42adb83d38ff60aa59baca06f58f2a71604f542cc8a284241cd0af5de525dc2c3b
|
7
|
+
data.tar.gz: 63faf6d869a494389564d6ec18680224b44e434a279b395bf90e1ca62081d82a69124794de590aa3d9ae58d35026c4a6fe7797568ad13db3e3b591aa3311c96b
|
data/CHANGELOG.asciidoc
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
= Pleaserun Changes and Releases
|
2
2
|
|
3
|
+
== 0.0.22 (May 18, 2016)
|
4
|
+
* systemd platform now defaults to targeting /etc/systemd/system for writing
|
5
|
+
unit files. This was chosen based on research across across 7 different
|
6
|
+
Linux distributions.
|
7
|
+
* fix a bug where attempting to detect systemd would crash becuase
|
8
|
+
`systemctl` was not available.
|
9
|
+
|
3
10
|
== 0.0.21 (May 16, 2016)
|
4
11
|
* Platform detection mechanism now looks for evidence that a given platform
|
5
12
|
is available (files, executables, etc). The previous mechanism used facter
|
data/Gemfile.lock
CHANGED
data/lib/pleaserun/detector.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "cabin"
|
2
2
|
require "open3"
|
3
|
+
require "pleaserun/namespace"
|
3
4
|
|
4
5
|
# Detect the service platform that's most likely to be successful on the
|
5
6
|
# running machine.
|
@@ -24,12 +25,9 @@ module PleaseRun::Detector
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def detect_systemd
|
27
|
-
# Expect a certain directory
|
28
|
-
return false unless File.directory?("/lib/systemd/system")
|
29
|
-
|
30
28
|
# Check the version. If `systemctl` fails, systemd isn't available.
|
31
|
-
out,
|
32
|
-
return false unless
|
29
|
+
out, success = execute([ "systemctl", "--version" ])
|
30
|
+
return false unless success
|
33
31
|
|
34
32
|
# version is the last word on the first line of the --version output
|
35
33
|
version = out.split("\n").first.split(/\s+/).last
|
@@ -41,8 +39,8 @@ module PleaseRun::Detector
|
|
41
39
|
return false unless File.directory?("/etc/init")
|
42
40
|
|
43
41
|
# Check the version. If `initctl` fails, upstart isn't available.
|
44
|
-
out,
|
45
|
-
return false unless
|
42
|
+
out, success = execute(["initctl", "--version"])
|
43
|
+
return false unless success
|
46
44
|
|
47
45
|
version = out.split("\n").first.tr("()", "").split(/\s+/).last
|
48
46
|
["upstart", version]
|
@@ -58,8 +56,8 @@ module PleaseRun::Detector
|
|
58
56
|
def detect_launchd
|
59
57
|
return false unless File.directory?("/Library/LaunchDaemons")
|
60
58
|
|
61
|
-
out,
|
62
|
-
return false unless
|
59
|
+
out, success = execute(["launchctl", "version"])
|
60
|
+
return false unless success
|
63
61
|
|
64
62
|
# TODO(sissel): Version?
|
65
63
|
version = out.split("\n").first.split(":").first.split(/\s+/).last
|
@@ -78,7 +76,11 @@ module PleaseRun::Detector
|
|
78
76
|
out = stdout.read
|
79
77
|
stderr.close
|
80
78
|
exit_status = wait_thr.value
|
81
|
-
return out, exit_status
|
79
|
+
return out, exit_status.success?
|
82
80
|
end
|
81
|
+
rescue Errno::ENOENT, Errno::EACCES => e
|
82
|
+
# If the path doesn't exist or we cannot execute it, return the exception
|
83
|
+
# message as the output and indicate a failure to run.
|
84
|
+
return e.message, false
|
83
85
|
end
|
84
86
|
end
|
@@ -5,6 +5,13 @@ require "pleaserun/platform/base"
|
|
5
5
|
#
|
6
6
|
# If you use Fedora 18+ or CentOS/RHEL 7+, this is for you.
|
7
7
|
class PleaseRun::Platform::Systemd < PleaseRun::Platform::Base
|
8
|
+
attribute :unit_path, "The path to put systemd unit files",
|
9
|
+
:default => "/etc/systemd/system" do
|
10
|
+
validate do |path|
|
11
|
+
insist { path }.is_a?(String)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
8
15
|
def files
|
9
16
|
begin
|
10
17
|
# TODO(sissel): Make it easy for subclasses to extend validation on attributes.
|
@@ -14,8 +21,10 @@ class PleaseRun::Platform::Systemd < PleaseRun::Platform::Base
|
|
14
21
|
end
|
15
22
|
|
16
23
|
return Enumerator::Generator.new do |enum|
|
17
|
-
enum.yield(safe_filename("/
|
18
|
-
|
24
|
+
enum.yield(safe_filename("{{{ unit_path }}}/{{{ name }}}.service"), render_template("program.service"))
|
25
|
+
|
26
|
+
# TODO(sissel): This is probably not the best place to put this. Ahh well :)
|
27
|
+
enum.yield(safe_filename("{{{ unit_path }}}/{{{ name }}}-prestart.sh"), render_template("prestart.sh"), 0755) if prestart
|
19
28
|
end
|
20
29
|
end # def files
|
21
30
|
|
data/pleaserun.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |spec|
|
|
2
2
|
files = File.read(__FILE__)[/^__END__$.*/m].split("\n")[1..-1]
|
3
3
|
|
4
4
|
spec.name = "pleaserun"
|
5
|
-
spec.version = "0.0.
|
5
|
+
spec.version = "0.0.22"
|
6
6
|
spec.summary = "pleaserun"
|
7
7
|
spec.description = "pleaserun"
|
8
8
|
spec.license = "Apache 2.0"
|
@@ -24,8 +24,10 @@ describe PleaseRun::Platform::Systemd do
|
|
24
24
|
|
25
25
|
let(:files) { subject.files.collect { |path, _| path } }
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
context "by default" do
|
28
|
+
it "emits a file in /etc/systemd/system" do
|
29
|
+
insist { files }.include?("/etc/systemd/system/fancypants.service")
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -14,7 +14,7 @@ EnvironmentFile=-/etc/default/{{{name}}}
|
|
14
14
|
EnvironmentFile=-/etc/sysconfig/{{{name}}}
|
15
15
|
ExecStart={{{program}}} {{{shell_args}}}
|
16
16
|
{{#prestart}}
|
17
|
-
ExecStartPre
|
17
|
+
ExecStartPre={{{unit_path}}}/{{{name}}}-prestart.sh
|
18
18
|
{{/prestart}}
|
19
19
|
Restart=always
|
20
20
|
WorkingDirectory={{{chdir}}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pleaserun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Sissel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cabin
|