pleaserun 0.0.1

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.
Files changed (44) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +73 -0
  4. data/Guardfile +17 -0
  5. data/Makefile +50 -0
  6. data/README.md +98 -0
  7. data/bin/pleaserun +7 -0
  8. data/examples/runit.rb +16 -0
  9. data/lib/pleaserun/cli.rb +241 -0
  10. data/lib/pleaserun/configurable.rb +143 -0
  11. data/lib/pleaserun/detector.rb +58 -0
  12. data/lib/pleaserun/mustache_methods.rb +41 -0
  13. data/lib/pleaserun/namespace.rb +3 -0
  14. data/lib/pleaserun/platform/base.rb +144 -0
  15. data/lib/pleaserun/platform/launchd.rb +27 -0
  16. data/lib/pleaserun/platform/runit.rb +18 -0
  17. data/lib/pleaserun/platform/systemd.rb +24 -0
  18. data/lib/pleaserun/platform/sysv.rb +12 -0
  19. data/lib/pleaserun/platform/upstart.rb +11 -0
  20. data/pleaserun.gemspec +27 -0
  21. data/spec/pleaserun/configurable_spec.rb +215 -0
  22. data/spec/pleaserun/mustache_methods_spec.rb +46 -0
  23. data/spec/pleaserun/platform/base_spec.rb +27 -0
  24. data/spec/pleaserun/platform/launchd_spec.rb +93 -0
  25. data/spec/pleaserun/platform/systemd_spec.rb +119 -0
  26. data/spec/pleaserun/platform/sysv_spec.rb +133 -0
  27. data/spec/pleaserun/platform/upstart_spec.rb +117 -0
  28. data/spec/testenv.rb +69 -0
  29. data/templates/launchd/10.9/program.plist +47 -0
  30. data/templates/runit/log +4 -0
  31. data/templates/runit/run +17 -0
  32. data/templates/systemd/default/prestart.sh +2 -0
  33. data/templates/systemd/default/program.service +17 -0
  34. data/templates/sysv/lsb-3.1/default +0 -0
  35. data/templates/sysv/lsb-3.1/init.d +141 -0
  36. data/templates/upstart/1.5/init.conf +41 -0
  37. data/templates/upstart/1.5/init.d.sh +4 -0
  38. data/test.rb +33 -0
  39. data/test/helpers.rb +20 -0
  40. data/test/test.rb +60 -0
  41. data/test/vagrant/Vagrantfile +40 -0
  42. data/test/vagrant/fedora-18/Vagrantfile +28 -0
  43. data/test/vagrant/fedora-18/provision.sh +10 -0
  44. metadata +187 -0
@@ -0,0 +1,41 @@
1
+ description "{{{ description }}}"
2
+ start on filesystem or runlevel [2345]
3
+ stop on runlevel [!2345]
4
+
5
+ respawn
6
+ umask {{{umask}}}
7
+ #nice {{{nice}}}
8
+ #chroot {{{chroot}}}
9
+ #chdir {{{chdir}}}
10
+ #limit core <softlimit> <hardlimit>
11
+ #limit cpu <softlimit> <hardlimit>
12
+ #limit data <softlimit> <hardlimit>
13
+ #limit fsize <softlimit> <hardlimit>
14
+ #limit memlock <softlimit> <hardlimit>
15
+ #limit msgqueue <softlimit> <hardlimit>
16
+ #limit nice <softlimit> <hardlimit>
17
+ #limit nofile <softlimit> <hardlimit>
18
+ #limit nproc <softlimit> <hardlimit>
19
+ #limit rss <softlimit> <hardlimit>
20
+ #limit rtprio <softlimit> <hardlimit>
21
+ #limit sigpending <softlimit> <hardlimit>
22
+ #limit stack <softlimit> <hardlimit>
23
+ setuid {{{user}}}
24
+ setgid {{{group}}}
25
+ console log # log stdout/stderr to /var/log/upstart/
26
+
27
+ {{#prestart}}
28
+ pre-start script
29
+ {{{ prestart }}}
30
+
31
+ status=$?
32
+ if [ "$status" -gt 0 ] ; then
33
+ echo "Prestart command failed with code $status."
34
+
35
+ # Per init(5) docs, simply calling 'stop' will abort this start.
36
+ stop
37
+ fi
38
+ end script
39
+ {{/prestart}}
40
+
41
+ exec {{{program}}} {{{shell_args}}}
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ echo "This job runs via upstart, invoking upstart now..."
4
+ exec initctl $1 {{name}}
data/test.rb ADDED
@@ -0,0 +1,33 @@
1
+ $: << "./lib"
2
+ require "pleaserun/sysv"
3
+ require "fpm"
4
+ require "fpm/package/dir"
5
+ require "pleaserun/runit"
6
+ pr = PleaseRun::SysVInit.new("ubuntu-12.04")
7
+ #pr = PleaseRun::Runit.new("")
8
+ pr.name = "test fancy"
9
+ pr.user = "root"
10
+ #pr.args = [ "-t", "sometag", "hello world" ]
11
+ #pr.command = "printf"
12
+ #pr.args = [ "1: %s\n2: %s\n3: %s\n", "3600", "hello world" ]
13
+ #
14
+ pr.program = "sleep"
15
+ pr.args = [ "3600" ]
16
+
17
+ pkg = FPM::Package::Dir.new
18
+ pkg.name = "example"
19
+ pr.files.each do |path, content|
20
+ #next unless path == "/service/test_fancy/run"
21
+ out = pkg.staging_path(path)
22
+ outdir = File.dirname(out)
23
+ FileUtils.mkdir_p(outdir)
24
+ File.write(out, content)
25
+ end
26
+ pkg.output("./example")
27
+
28
+ #* identity (user, group)
29
+ #* limits (ulimit, etc)
30
+ #* environment variables
31
+ #* working directory
32
+ #* containers (chroot, etc)
33
+ #* log/output locations
data/test/helpers.rb ADDED
@@ -0,0 +1,20 @@
1
+ class Stud::Try
2
+ # Make Stud::Try quiet.
3
+ def log_failure(*args); end
4
+ end
5
+
6
+ def test_in_container(tag, commands, outfile, errfile)
7
+ chdir = File.join(File.dirname(__FILE__), "vagrant")
8
+ system("cd #{chdir}; vagrant up #{tag} > #{outfile} 2> #{errfile}")
9
+ insist { $? }.success?
10
+
11
+ commands.each do |command|
12
+ IO.popen("cd #{chdir}; vagrant ssh #{tag} -- sudo bash -l >> #{outfile} 2>> #{errfile}", "w") do |io|
13
+ io.puts(command)
14
+ io.puts("exit $?")
15
+ io.close_write
16
+ end
17
+ insist { $? } == 0
18
+ end
19
+ return $?.success?
20
+ end
data/test/test.rb ADDED
@@ -0,0 +1,60 @@
1
+ require "insist"
2
+ require "net/ssh"
3
+ require "json"
4
+ require "stud/try"
5
+ require "stud/temporary"
6
+ require "peach"
7
+
8
+ require_relative "helpers"
9
+ Thread.abort_on_exception = true
10
+
11
+ raise "What tags to run?" if ARGV.empty?
12
+
13
+ start = Time.now
14
+ queue = Queue.new
15
+
16
+ puts "Testing on #{ARGV.size} platforms:"
17
+ puts ARGV.join(", ")
18
+ puts
19
+ ARGV.each do |tag|
20
+ Thread.new do
21
+ out = Stud::Temporary.pathname
22
+ err = Stud::Temporary.pathname
23
+ begin
24
+ status = test_in_container(tag, [
25
+ ". /etc/profile; cd /pleaserun; rvm use 1.9.3; bundle install --quiet",
26
+ ". /etc/profile; cd /pleaserun; rvm use 1.9.3; rspec --format json"
27
+ ], out, err)
28
+ rescue Insist::Failure
29
+ status = false
30
+ end
31
+ queue << [tag, status, out, err]
32
+ end
33
+ end
34
+
35
+ results = ARGV.collect { tag, success, out, err = queue.pop }
36
+ successes = results.count { |tag, success, out, err| success }
37
+ failures = results.count { |tag, success, out, err| !success }
38
+ total_tests = 0
39
+ tests = results.collect { |tag, success, out, err|
40
+ JSON.parse(File.read(out).split("\n").last[/{.*$/])["examples"].each { |r| r["tag"] = tag }
41
+ }.flatten
42
+
43
+ duration = Time.now - start
44
+
45
+ test_successes = tests.count { |t| t["status"] == "passed" }
46
+ test_failures = tests.count { |t| t["status"] == "failed" }
47
+
48
+ puts "Tests: #{test_successes} ok, #{test_failures} failures; Platforms: #{successes} ok, #{failures} failures;, Duration: #{sprintf("%0.3f", duration)} seconds"
49
+
50
+ results.each do |tag, success, out, err|
51
+ # print only on failure *or* if only one container is run
52
+ if !success || results.size == 1
53
+ puts File.read(err).gsub(/^/, "#{tag}/stderr: ")
54
+ puts File.read(out).gsub(/^/, "#{tag}/stdout: ")
55
+ end
56
+ File.delete(err)
57
+ File.delete(out)
58
+ end
59
+
60
+ exit(results.any? { |t,s,*args| !s } ? 1 : 0)
@@ -0,0 +1,40 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ root = File.expand_path("../../", File.dirname(__FILE__))
9
+ config.vm.synced_folder root, "/pleaserun"
10
+
11
+ # Ubuntu
12
+ %w(12.04 12.10 13.04 13.10).each do |version|
13
+ config.vm.define "ubuntu-#{version}" do |c|
14
+ c.vm.box = "dummy"
15
+ c.vm.box_url = "http://bit.ly/vagrant-docker-dummy"
16
+ c.vm.provider :docker do |docker|
17
+ docker.image = "jordansissel/system:ubuntu-#{version}"
18
+ end
19
+ end
20
+ end
21
+
22
+ # Debian
23
+ %w(7.3 6.0.8).each do |version|
24
+ config.vm.define "debian-#{version}" do |c|
25
+ c.vm.box = "dummy"
26
+ c.vm.box_url = "http://bit.ly/vagrant-docker-dummy"
27
+ c.vm.provider :docker do |docker|
28
+ docker.image = "jordansissel/system:debian-#{version}"
29
+ end
30
+ end
31
+ end
32
+
33
+ # Fedora
34
+ config.vm.define "fedora-18" do |c|
35
+ c.vm.box = "fedora-18"
36
+ c.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box"
37
+ c.vm.provider "virtualbox"
38
+ c.vm.provision "shell", :path => "fedora-18/provision.sh"
39
+ end
40
+ end
@@ -0,0 +1,28 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ # All Vagrant configuration is done here. The most common configuration
9
+ # options are documented and commented below. For a complete reference,
10
+ # please see the online documentation at vagrantup.com.
11
+
12
+ # Every Vagrant virtual environment requires a box to build off of.
13
+ config.vm.box = "fedora-18"
14
+
15
+ # The url from where the 'config.vm.box' box will be fetched if it
16
+ # doesn't already exist on the user's system.
17
+ config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box"
18
+
19
+ # Share an additional folder to the guest VM. The first argument is
20
+ # the path on the host to the actual folder. The second argument is
21
+ # the path on the guest to mount the folder. And the optional third
22
+ # argument is a set of non-required options.
23
+ # config.vm.synced_folder "../data", "/vagrant_data"
24
+
25
+ config.vm.provision "shell", :path => "provision.sh"
26
+
27
+ config.vm.synced_folder "../../../", "/pleaserun"
28
+ end
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ [ `whoami` != "vagrant" ] && chroot --userspec=vagrant / bash -l "$@"
4
+
5
+ export USER=`whoami`
6
+ export HOME=/home/vagrant
7
+
8
+ [ ! -f "$HOME/.rvm/scripts/rvm" ] && curl -sSL https://get.rvm.io | bash -s stable
9
+ . "$HOME/.rvm/scripts/rvm"
10
+ rvm list | grep -q 'No rvm rubies' && rvm install 1.9.3
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pleaserun
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jordan Sissel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cabin
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>'
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>'
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: clamp
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: cabin
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: stud
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: mustache
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: insist
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: pleaserun
111
+ email:
112
+ - jls@semicomplete.com
113
+ executables:
114
+ - pleaserun
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - Gemfile.lock
121
+ - Guardfile
122
+ - Makefile
123
+ - README.md
124
+ - bin/pleaserun
125
+ - examples/runit.rb
126
+ - lib/pleaserun/cli.rb
127
+ - lib/pleaserun/configurable.rb
128
+ - lib/pleaserun/detector.rb
129
+ - lib/pleaserun/mustache_methods.rb
130
+ - lib/pleaserun/namespace.rb
131
+ - lib/pleaserun/platform/base.rb
132
+ - lib/pleaserun/platform/launchd.rb
133
+ - lib/pleaserun/platform/runit.rb
134
+ - lib/pleaserun/platform/systemd.rb
135
+ - lib/pleaserun/platform/sysv.rb
136
+ - lib/pleaserun/platform/upstart.rb
137
+ - pleaserun.gemspec
138
+ - spec/pleaserun/configurable_spec.rb
139
+ - spec/pleaserun/mustache_methods_spec.rb
140
+ - spec/pleaserun/platform/base_spec.rb
141
+ - spec/pleaserun/platform/launchd_spec.rb
142
+ - spec/pleaserun/platform/systemd_spec.rb
143
+ - spec/pleaserun/platform/sysv_spec.rb
144
+ - spec/pleaserun/platform/upstart_spec.rb
145
+ - spec/testenv.rb
146
+ - templates/launchd/10.9/program.plist
147
+ - templates/runit/log
148
+ - templates/runit/run
149
+ - templates/systemd/default/prestart.sh
150
+ - templates/systemd/default/program.service
151
+ - templates/sysv/lsb-3.1/default
152
+ - templates/sysv/lsb-3.1/init.d
153
+ - templates/upstart/1.5/init.conf
154
+ - templates/upstart/1.5/init.d.sh
155
+ - test.rb
156
+ - test/helpers.rb
157
+ - test/test.rb
158
+ - test/vagrant/Vagrantfile
159
+ - test/vagrant/fedora-18/Vagrantfile
160
+ - test/vagrant/fedora-18/provision.sh
161
+ homepage:
162
+ licenses:
163
+ - Apache 2.0
164
+ post_install_message:
165
+ rdoc_options: []
166
+ require_paths:
167
+ - lib
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ none: false
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 1.8.24
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: pleaserun
187
+ test_files: []