pleaserun 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1607c72a99aa0a0bb5f3513e132c32c4ed64b340
4
- data.tar.gz: 5aa785212a00ed91a9dfe31a09a63da531c4d1a8
3
+ metadata.gz: f7e0519711adf2648e38698c8e3aca1b736f4c4e
4
+ data.tar.gz: 8ea0617089d0b51121baffb1afe909f223b56ce3
5
5
  SHA512:
6
- metadata.gz: 5d3279e7c1bf924033659d3a11ab28fca8688208df956199a641f5e234fbf11d36d818375a091eeafadc353d397e2a0b1ad0b65f58ee592e9908b8cec630c086
7
- data.tar.gz: 105778d5a15040001808f335a4737b98e9ff70860e06b323b113a19119f6ff98eb3b4912cf0ff387e4817480c969708f4fdb05dc786015ca292cbc60dbf17447
6
+ metadata.gz: 4161d65cabbb8f8668e2a3a088b76c25533bb5efe98350b81b5582d22f6fbd42adb83d38ff60aa59baca06f58f2a71604f542cc8a284241cd0af5de525dc2c3b
7
+ data.tar.gz: 63faf6d869a494389564d6ec18680224b44e434a279b395bf90e1ca62081d82a69124794de590aa3d9ae58d35026c4a6fe7797568ad13db3e3b591aa3311c96b
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pleaserun (0.0.20)
4
+ pleaserun (0.0.21)
5
5
  cabin (> 0)
6
6
  clamp
7
7
  insist
@@ -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, status = execute([ "systemctl", "--version" ])
32
- return false unless status.success?
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, status = execute(["initctl", "--version"])
45
- return false unless status.success?
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, status = execute(["launchctl", "version"])
62
- return false unless status.success?
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("/lib/systemd/system/{{{ name }}}.service"), render_template("program.service"))
18
- enum.yield(safe_filename("/lib/systemd/system/{{{ name }}}-prestart.sh"), render_template("prestart.sh"), 0755) if prestart
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
 
@@ -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.21"
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
- it "emits a file in /lib/systemd/system" do
28
- insist { files }.include?("/lib/systemd/system/fancypants.service")
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=/lib/systemd/system/{{{name}}}-prestart.sh
17
+ ExecStartPre={{{unit_path}}}/{{{name}}}-prestart.sh
18
18
  {{/prestart}}
19
19
  Restart=always
20
20
  WorkingDirectory={{{chdir}}}
@@ -26,6 +26,8 @@ pidfile="/var/run/$name.pid"
26
26
  [ -r /etc/default/$name ] && . /etc/default/$name
27
27
  [ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name
28
28
 
29
+ [ -z "$nice" ] && nice=0
30
+
29
31
  trace() {
30
32
  logger -t "/etc/init.d/{{{name}}}" "$@"
31
33
  }
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.21
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-15 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cabin