foreman-capistrano 0.51.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/README.md +46 -0
  2. data/bin/foreman +7 -0
  3. data/bin/foreman-runner +32 -0
  4. data/bin/taskman +8 -0
  5. data/data/example/Procfile +4 -0
  6. data/data/example/Procfile.without_colon +2 -0
  7. data/data/example/error +7 -0
  8. data/data/example/log/neverdie.log +4 -0
  9. data/data/example/spawnee +14 -0
  10. data/data/example/spawner +7 -0
  11. data/data/example/ticker +14 -0
  12. data/data/example/utf8 +11 -0
  13. data/data/export/bluepill/master.pill.erb +28 -0
  14. data/data/export/launchd/launchd.plist.erb +22 -0
  15. data/data/export/runit/log/run.erb +7 -0
  16. data/data/export/runit/run.erb +3 -0
  17. data/data/export/supervisord/app.conf.erb +27 -0
  18. data/data/export/upstart/master.conf.erb +8 -0
  19. data/data/export/upstart/process.conf.erb +7 -0
  20. data/data/export/upstart/process_master.conf.erb +2 -0
  21. data/lib/foreman/capistrano.rb +55 -0
  22. data/lib/foreman/cli.rb +140 -0
  23. data/lib/foreman/distribution.rb +9 -0
  24. data/lib/foreman/engine/cli.rb +104 -0
  25. data/lib/foreman/engine.rb +313 -0
  26. data/lib/foreman/env.rb +27 -0
  27. data/lib/foreman/export/base.rb +146 -0
  28. data/lib/foreman/export/bluepill.rb +12 -0
  29. data/lib/foreman/export/inittab.rb +33 -0
  30. data/lib/foreman/export/launchd.rb +15 -0
  31. data/lib/foreman/export/runit.rb +34 -0
  32. data/lib/foreman/export/supervisord.rb +16 -0
  33. data/lib/foreman/export/upstart.rb +25 -0
  34. data/lib/foreman/export.rb +34 -0
  35. data/lib/foreman/helpers.rb +45 -0
  36. data/lib/foreman/process.rb +102 -0
  37. data/lib/foreman/procfile.rb +92 -0
  38. data/lib/foreman/version.rb +5 -0
  39. data/lib/foreman.rb +23 -0
  40. data/man/foreman.1 +244 -0
  41. data/spec/foreman/cli_spec.rb +87 -0
  42. data/spec/foreman/engine_spec.rb +104 -0
  43. data/spec/foreman/export/base_spec.rb +19 -0
  44. data/spec/foreman/export/bluepill_spec.rb +37 -0
  45. data/spec/foreman/export/inittab_spec.rb +40 -0
  46. data/spec/foreman/export/launchd_spec.rb +21 -0
  47. data/spec/foreman/export/runit_spec.rb +36 -0
  48. data/spec/foreman/export/supervisord_spec.rb +36 -0
  49. data/spec/foreman/export/upstart_spec.rb +88 -0
  50. data/spec/foreman/export_spec.rb +24 -0
  51. data/spec/foreman/helpers_spec.rb +26 -0
  52. data/spec/foreman/process_spec.rb +48 -0
  53. data/spec/foreman/procfile_spec.rb +41 -0
  54. data/spec/foreman_spec.rb +16 -0
  55. data/spec/helper_spec.rb +18 -0
  56. data/spec/resources/Procfile +4 -0
  57. data/spec/resources/bin/echo +2 -0
  58. data/spec/resources/bin/env +2 -0
  59. data/spec/resources/bin/test +2 -0
  60. data/spec/resources/bin/utf8 +2 -0
  61. data/spec/resources/export/bluepill/app-concurrency.pill +49 -0
  62. data/spec/resources/export/bluepill/app.pill +46 -0
  63. data/spec/resources/export/inittab/inittab.concurrency +4 -0
  64. data/spec/resources/export/inittab/inittab.default +4 -0
  65. data/spec/resources/export/launchd/launchd-a.default +22 -0
  66. data/spec/resources/export/launchd/launchd-b.default +22 -0
  67. data/spec/resources/export/runit/app-alpha-1/log/run +7 -0
  68. data/spec/resources/export/runit/app-alpha-1/run +3 -0
  69. data/spec/resources/export/runit/app-alpha-2/log/run +7 -0
  70. data/spec/resources/export/runit/app-alpha-2/run +3 -0
  71. data/spec/resources/export/runit/app-bravo-1/log/run +7 -0
  72. data/spec/resources/export/runit/app-bravo-1/run +3 -0
  73. data/spec/resources/export/supervisord/app-alpha-1.conf +24 -0
  74. data/spec/resources/export/supervisord/app-alpha-2.conf +24 -0
  75. data/spec/resources/export/upstart/app-alpha-1.conf +5 -0
  76. data/spec/resources/export/upstart/app-alpha-2.conf +5 -0
  77. data/spec/resources/export/upstart/app-alpha.conf +2 -0
  78. data/spec/resources/export/upstart/app-bravo-1.conf +5 -0
  79. data/spec/resources/export/upstart/app-bravo.conf +2 -0
  80. data/spec/resources/export/upstart/app.conf +8 -0
  81. data/spec/spec_helper.rb +153 -0
  82. metadata +145 -0
@@ -0,0 +1,24 @@
1
+
2
+ [program:app-alpha-1]
3
+ command=./alpha
4
+ autostart=true
5
+ autorestart=true
6
+ stopsignal=QUIT
7
+ stdout_logfile=/var/log/app/alpha-1.log
8
+ stderr_logfile=/var/log/app/alpha-1.error.log
9
+ user=app
10
+ directory=/tmp/app
11
+ environment=PORT="5000"
12
+ [program:app-bravo-1]
13
+ command=./bravo
14
+ autostart=true
15
+ autorestart=true
16
+ stopsignal=QUIT
17
+ stdout_logfile=/var/log/app/bravo-1.log
18
+ stderr_logfile=/var/log/app/bravo-1.error.log
19
+ user=app
20
+ directory=/tmp/app
21
+ environment=PORT="5100"
22
+
23
+ [group:app]
24
+ programs=app-alpha-1,app-bravo-1
@@ -0,0 +1,24 @@
1
+
2
+ [program:app-alpha-1]
3
+ command=./alpha
4
+ autostart=true
5
+ autorestart=true
6
+ stopsignal=QUIT
7
+ stdout_logfile=/var/log/app/alpha-1.log
8
+ stderr_logfile=/var/log/app/alpha-1.error.log
9
+ user=app
10
+ directory=/tmp/app
11
+ environment=PORT="5000"
12
+ [program:app-alpha-2]
13
+ command=./alpha
14
+ autostart=true
15
+ autorestart=true
16
+ stopsignal=QUIT
17
+ stdout_logfile=/var/log/app/alpha-2.log
18
+ stderr_logfile=/var/log/app/alpha-2.error.log
19
+ user=app
20
+ directory=/tmp/app
21
+ environment=PORT="5001"
22
+
23
+ [group:app]
24
+ programs=app-alpha-1,app-alpha-2
@@ -0,0 +1,5 @@
1
+ start on starting app-alpha
2
+ stop on stopping app-alpha
3
+ respawn
4
+
5
+ exec su - app -c 'cd /tmp/app; export PORT=5000; ./alpha >> /var/log/app/alpha-1.log 2>&1'
@@ -0,0 +1,5 @@
1
+ start on starting app-alpha
2
+ stop on stopping app-alpha
3
+ respawn
4
+
5
+ exec su - app -c 'cd /tmp/app; export PORT=5001; ./alpha >> /var/log/app/alpha-2.log 2>&1'
@@ -0,0 +1,2 @@
1
+ start on starting app
2
+ stop on stopping app
@@ -0,0 +1,5 @@
1
+ start on starting app-bravo
2
+ stop on stopping app-bravo
3
+ respawn
4
+
5
+ exec su - app -c 'cd /tmp/app; export PORT=5100; ./bravo >> /var/log/app/bravo-1.log 2>&1'
@@ -0,0 +1,2 @@
1
+ start on starting app
2
+ stop on stopping app
@@ -0,0 +1,8 @@
1
+ pre-start script
2
+
3
+ bash << "EOF"
4
+ mkdir -p /var/log/app
5
+ chown -R app /var/log/app
6
+ EOF
7
+
8
+ end script
@@ -0,0 +1,153 @@
1
+ require "rubygems"
2
+
3
+ require "simplecov"
4
+ SimpleCov.start do
5
+ add_filter "/spec/"
6
+ end
7
+
8
+ require "rspec"
9
+ require "timecop"
10
+ require "fakefs/safe"
11
+ require "fakefs/spec_helpers"
12
+
13
+ $:.unshift File.expand_path("../../lib", __FILE__)
14
+
15
+ def mock_export_error(message)
16
+ lambda { yield }.should raise_error(Foreman::Export::Exception, message)
17
+ end
18
+
19
+ def mock_error(subject, message)
20
+ mock_exit do
21
+ mock(subject).puts("ERROR: #{message}")
22
+ yield
23
+ end
24
+ end
25
+
26
+ def foreman(args)
27
+ capture_stdout do
28
+ begin
29
+ Foreman::CLI.start(args.split(" "))
30
+ rescue SystemExit
31
+ end
32
+ end
33
+ end
34
+
35
+ def forked_foreman(args)
36
+ rd, wr = IO.pipe("BINARY")
37
+ Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
38
+ wr.close
39
+ rd.read
40
+ end
41
+
42
+ def fork_and_capture(&blk)
43
+ rd, wr = IO.pipe("BINARY")
44
+ pid = fork do
45
+ rd.close
46
+ wr.sync = true
47
+ $stdout.reopen wr
48
+ $stderr.reopen wr
49
+ blk.call
50
+ $stdout.flush
51
+ $stdout.close
52
+ end
53
+ wr.close
54
+ Process.wait pid
55
+ buffer = ""
56
+ until rd.eof?
57
+ buffer += rd.gets
58
+ end
59
+ end
60
+
61
+ def mock_exit(&block)
62
+ block.should raise_error(SystemExit)
63
+ end
64
+
65
+ def write_foreman_config(app)
66
+ File.open("/etc/foreman/#{app}.conf", "w") do |file|
67
+ file.puts %{#{app}_processes="alpha bravo"}
68
+ file.puts %{#{app}_alpha="1"}
69
+ file.puts %{#{app}_bravo="2"}
70
+ end
71
+ end
72
+
73
+ def write_procfile(procfile="Procfile", alpha_env="")
74
+ File.open(procfile, "w") do |file|
75
+ file.puts "alpha: ./alpha" + " #{alpha_env}".rstrip
76
+ file.puts "\n"
77
+ file.puts "bravo:\t./bravo"
78
+ end
79
+ File.expand_path(procfile)
80
+ end
81
+
82
+ def write_env(env=".env", options={"FOO"=>"bar"})
83
+ File.open(env, "w") do |file|
84
+ options.each do |key, val|
85
+ file.puts "#{key}=#{val}"
86
+ end
87
+ end
88
+ end
89
+
90
+ def without_fakefs
91
+ FakeFS.deactivate!
92
+ ret = yield
93
+ FakeFS.activate!
94
+ ret
95
+ end
96
+
97
+ def load_export_templates_into_fakefs(type)
98
+ without_fakefs do
99
+ Dir[File.expand_path("../../data/export/#{type}/**/*", __FILE__)].inject({}) do |hash, file|
100
+ next(hash) if File.directory?(file)
101
+ hash.update(file => File.read(file))
102
+ end
103
+ end.each do |filename, contents|
104
+ FileUtils.mkdir_p File.dirname(filename)
105
+ File.open(filename, "w") do |f|
106
+ f.puts contents
107
+ end
108
+ end
109
+ end
110
+
111
+ def resource_path(filename)
112
+ File.expand_path("../resources/#{filename}", __FILE__)
113
+ end
114
+
115
+ def example_export_file(filename)
116
+ FakeFS.deactivate!
117
+ data = File.read(File.expand_path(resource_path("export/#{filename}"), __FILE__))
118
+ FakeFS.activate!
119
+ data
120
+ end
121
+
122
+ def preserving_env
123
+ old_env = ENV.to_hash
124
+ begin
125
+ yield
126
+ ensure
127
+ ENV.clear
128
+ ENV.update(old_env)
129
+ end
130
+ end
131
+
132
+ def normalize_space(s)
133
+ s.gsub(/\n[\n\s]*/, "\n")
134
+ end
135
+
136
+ def capture_stdout
137
+ old_stdout = $stdout.dup
138
+ rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
139
+ $stdout = wr
140
+ yield
141
+ wr.close
142
+ rd.read
143
+ ensure
144
+ $stdout = old_stdout
145
+ end
146
+
147
+ RSpec.configure do |config|
148
+ config.treat_symbols_as_metadata_keys_with_true_values = true
149
+ config.color_enabled = true
150
+ config.order = 'rand'
151
+ config.include FakeFS::SpecHelpers, :fakefs
152
+ config.mock_with :rr
153
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman-capistrano
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.51.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Dollar, Gropher
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.13.6
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.13.6
30
+ description: Process manager for applications with multiple components + capistrano
31
+ support out of the box
32
+ email: ddollar@gmail.com, grophen@gmail.com
33
+ executables:
34
+ - foreman
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - README.md
39
+ - lib/foreman.rb
40
+ - lib/foreman/env.rb
41
+ - lib/foreman/engine.rb
42
+ - lib/foreman/procfile.rb
43
+ - lib/foreman/distribution.rb
44
+ - lib/foreman/export/bluepill.rb
45
+ - lib/foreman/export/supervisord.rb
46
+ - lib/foreman/export/runit.rb
47
+ - lib/foreman/export/inittab.rb
48
+ - lib/foreman/export/upstart.rb
49
+ - lib/foreman/export/base.rb
50
+ - lib/foreman/export/launchd.rb
51
+ - lib/foreman/process.rb
52
+ - lib/foreman/export.rb
53
+ - lib/foreman/version.rb
54
+ - lib/foreman/engine/cli.rb
55
+ - lib/foreman/helpers.rb
56
+ - lib/foreman/cli.rb
57
+ - lib/foreman/capistrano.rb
58
+ - spec/resources/bin/echo
59
+ - spec/resources/bin/test
60
+ - spec/resources/bin/env
61
+ - spec/resources/bin/utf8
62
+ - spec/resources/export/inittab/inittab.default
63
+ - spec/resources/export/inittab/inittab.concurrency
64
+ - spec/resources/export/runit/app-alpha-1/run
65
+ - spec/resources/export/runit/app-alpha-1/log/run
66
+ - spec/resources/export/runit/app-alpha-2/run
67
+ - spec/resources/export/runit/app-alpha-2/log/run
68
+ - spec/resources/export/runit/app-bravo-1/run
69
+ - spec/resources/export/runit/app-bravo-1/log/run
70
+ - spec/resources/export/upstart/app-alpha.conf
71
+ - spec/resources/export/upstart/app-alpha-2.conf
72
+ - spec/resources/export/upstart/app-bravo.conf
73
+ - spec/resources/export/upstart/app.conf
74
+ - spec/resources/export/upstart/app-bravo-1.conf
75
+ - spec/resources/export/upstart/app-alpha-1.conf
76
+ - spec/resources/export/bluepill/app.pill
77
+ - spec/resources/export/bluepill/app-concurrency.pill
78
+ - spec/resources/export/launchd/launchd-b.default
79
+ - spec/resources/export/launchd/launchd-a.default
80
+ - spec/resources/export/supervisord/app-alpha-2.conf
81
+ - spec/resources/export/supervisord/app-alpha-1.conf
82
+ - spec/resources/Procfile
83
+ - spec/foreman/export_spec.rb
84
+ - spec/foreman/helpers_spec.rb
85
+ - spec/foreman/procfile_spec.rb
86
+ - spec/foreman/cli_spec.rb
87
+ - spec/foreman/export/inittab_spec.rb
88
+ - spec/foreman/export/supervisord_spec.rb
89
+ - spec/foreman/export/base_spec.rb
90
+ - spec/foreman/export/upstart_spec.rb
91
+ - spec/foreman/export/runit_spec.rb
92
+ - spec/foreman/export/bluepill_spec.rb
93
+ - spec/foreman/export/launchd_spec.rb
94
+ - spec/foreman/process_spec.rb
95
+ - spec/foreman/engine_spec.rb
96
+ - spec/spec_helper.rb
97
+ - spec/foreman_spec.rb
98
+ - spec/helper_spec.rb
99
+ - bin/taskman
100
+ - bin/foreman
101
+ - bin/foreman-runner
102
+ - data/export/runit/log/run.erb
103
+ - data/export/runit/run.erb
104
+ - data/export/upstart/process.conf.erb
105
+ - data/export/upstart/master.conf.erb
106
+ - data/export/upstart/process_master.conf.erb
107
+ - data/export/bluepill/master.pill.erb
108
+ - data/export/launchd/launchd.plist.erb
109
+ - data/export/supervisord/app.conf.erb
110
+ - data/example/ticker
111
+ - data/example/Procfile
112
+ - data/example/utf8
113
+ - data/example/log/neverdie.log
114
+ - data/example/spawner
115
+ - data/example/spawnee
116
+ - data/example/Procfile.without_colon
117
+ - data/example/error
118
+ - man/foreman.1
119
+ homepage: http://github.com/Gropher/foreman
120
+ licenses: []
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.24
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Process manager for applications with multiple components + capistrano support
143
+ out of the box
144
+ test_files: []
145
+ has_rdoc: