foreman 0.63.0-mingw32 → 0.66.0-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README.md +1 -0
  2. data/data/export/bluepill/master.pill.erb +1 -1
  3. data/data/export/daemon/master.conf.erb +14 -0
  4. data/data/export/daemon/process.conf.erb +8 -0
  5. data/data/export/daemon/process_master.conf.erb +2 -0
  6. data/data/export/runit/log/run.erb +1 -1
  7. data/data/export/runit/run.erb +1 -0
  8. data/data/export/supervisord/app.conf.erb +1 -1
  9. data/data/export/systemd/master.target.erb +6 -0
  10. data/data/export/systemd/process.service.erb +15 -0
  11. data/data/export/systemd/process_master.target.erb +3 -0
  12. data/data/export/upstart/master.conf.erb +1 -11
  13. data/data/export/upstart/process.conf.erb +10 -1
  14. data/lib/foreman/cli.rb +10 -0
  15. data/lib/foreman/engine.rb +7 -2
  16. data/lib/foreman/export.rb +2 -0
  17. data/lib/foreman/export/base.rb +12 -2
  18. data/lib/foreman/export/daemon.rb +28 -0
  19. data/lib/foreman/export/launchd.rb +6 -1
  20. data/lib/foreman/export/systemd.rb +32 -0
  21. data/lib/foreman/process.rb +17 -13
  22. data/lib/foreman/version.rb +1 -1
  23. data/man/foreman.1 +23 -2
  24. data/spec/foreman/cli_spec.rb +15 -0
  25. data/spec/foreman/export/daemon_spec.rb +97 -0
  26. data/spec/foreman/export/systemd_spec.rb +91 -0
  27. data/spec/foreman/process_spec.rb +1 -1
  28. data/spec/resources/Procfile +1 -0
  29. data/spec/resources/export/daemon/app-alpha-1.conf +7 -0
  30. data/spec/resources/export/daemon/app-alpha-2.conf +7 -0
  31. data/spec/resources/export/daemon/app-alpha.conf +2 -0
  32. data/spec/resources/export/daemon/app-bravo-1.conf +7 -0
  33. data/spec/resources/export/daemon/app-bravo.conf +2 -0
  34. data/spec/resources/export/daemon/app.conf +14 -0
  35. data/spec/resources/export/runit/app-alpha-1/log/run +1 -1
  36. data/spec/resources/export/runit/app-alpha-2/log/run +1 -1
  37. data/spec/resources/export/runit/app-bravo-1/log/run +1 -1
  38. data/spec/resources/export/supervisord/app-alpha-1.conf +4 -4
  39. data/spec/resources/export/supervisord/app-alpha-2.conf +2 -2
  40. data/spec/resources/export/systemd/app-alpha-1.service +17 -0
  41. data/spec/resources/export/systemd/app-alpha-2.service +17 -0
  42. data/spec/resources/export/systemd/app-alpha.target +5 -0
  43. data/spec/resources/export/systemd/app-bravo-1.service +17 -0
  44. data/spec/resources/export/systemd/app-bravo.target +5 -0
  45. data/spec/resources/export/systemd/app.target +1 -0
  46. data/spec/spec_helper.rb +27 -5
  47. metadata +50 -15
  48. data/bin/taskman +0 -8
  49. data/lib/foreman/capistrano.rb +0 -54
data/README.md CHANGED
@@ -32,6 +32,7 @@ Manage Procfile-based applications
32
32
  * [shoreman](https://github.com/hecticjeff/shoreman) - shell
33
33
  * [honcho](https://github.com/nickstenning/honcho) - python
34
34
  * [norman](https://github.com/josh/norman) - node.js
35
+ * [forego](https://github.com/ddollar/forego) - Go
35
36
 
36
37
  ## Authors
37
38
 
@@ -7,7 +7,7 @@ Bluepill.application("<%= app %>", :foreground => false, :log_file => "/var/log/
7
7
  <% 1.upto(engine.formation[name]) do |num| %>
8
8
  <% port = engine.port_for(process, num) %>
9
9
  app.process("<%= name %>-<%= num %>") do |process|
10
- process.start_command = "<%= process.command %>"
10
+ process.start_command = %Q{<%= process.command %>}
11
11
 
12
12
  process.working_dir = "<%= engine.root %>"
13
13
  process.daemonize = true
@@ -0,0 +1,14 @@
1
+ pre-start script
2
+
3
+ bash << "EOF"
4
+ mkdir -p <%= log %>
5
+ chown -R <%= user %> <%= log %>
6
+ mkdir -p <%= run %>
7
+ chown -R <%= user %> <%= run %>
8
+ EOF
9
+
10
+ end script
11
+
12
+ start on runlevel [2345]
13
+
14
+ stop on runlevel [016]
@@ -0,0 +1,8 @@
1
+ start on starting <%= app %>-<%= name.gsub('_', '-') %>
2
+ stop on stopping <%= app %>-<%= name.gsub('_', '-') %>
3
+ respawn
4
+
5
+ env PORT=<%= port %><% engine.env.each_pair do |var, env| %>
6
+ env <%= var.upcase %>=<%= env %><% end %>
7
+
8
+ exec start-stop-daemon --start --chuid <%= user %> --chdir <%= engine.root %> --make-pidfile --pidfile <%= run %>/<%= app %>-<%= name %>-<%= num %>.pid --exec <%= executable %><%= arguments %> >> <%= log %>/<%= app %>-<%= name %>-<%= num %>.log 2>&1
@@ -0,0 +1,2 @@
1
+ start on starting <%= app %>
2
+ stop on stopping <%= app %>
@@ -3,5 +3,5 @@ set -e
3
3
 
4
4
  LOG=<%= log %>/<%= name %>-<%= num %>
5
5
 
6
- test -d "$LOG" || mkdir -p m2750 "$LOG" && chown <%= user %> "$LOG"
6
+ test -d "$LOG" || mkdir -p -m 2750 "$LOG" && chown <%= user %> "$LOG"
7
7
  exec chpst -u <%= user %> svlogd "$LOG"
@@ -1,3 +1,4 @@
1
1
  #!/bin/sh
2
2
  cd <%= engine.root %>
3
+ exec 2>&1
3
4
  exec chpst -u <%= user %> -e <%= File.join(location, "#{process_directory}/env") %> <%= process.command %>
@@ -5,7 +5,7 @@ engine.each_process do |name, process|
5
5
  port = engine.port_for(process, num)
6
6
  full_name = "#{app}-#{name}-#{num}"
7
7
  environment = engine.env.merge("PORT" => port.to_s).map do |key, value|
8
- "#{key}=#{shell_quote(value)}"
8
+ "#{key}=\"#{shell_quote(value)}\""
9
9
  end
10
10
  app_names << full_name
11
11
  %>
@@ -0,0 +1,6 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+ Wants=<%= process_master_names.join(' ') %>
4
+
5
+ [Install]
6
+ WantedBy=multi-user.target
@@ -0,0 +1,15 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+
4
+ [Service]
5
+ User=<%= user %>
6
+ WorkingDirectory=<%= engine.root %>
7
+ Environment=PORT=<%= port %><% engine.env.each_pair do |var,env| %>
8
+ Environment=<%= var.upcase %>=<%= env %><% end %>
9
+ ExecStart=/bin/bash -lc '<%= process.command %>'
10
+ Restart=always
11
+ StandardInput=null
12
+ StandardOutput=syslog
13
+ StandardError=syslog
14
+ SyslogIdentifier=%n
15
+ KillMode=process
@@ -0,0 +1,3 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+ Wants=<%= process_names.join(' ') %>
@@ -1,12 +1,2 @@
1
- pre-start script
2
-
3
- bash << "EOF"
4
- mkdir -p <%= log %>
5
- chown -R <%= user %> <%= log %>
6
- EOF
7
-
8
- end script
9
-
10
1
  start on runlevel [2345]
11
-
12
- stop on runlevel [016]
2
+ stop on runlevel [!2345]
@@ -2,4 +2,13 @@ start on starting <%= app %>-<%= name %>
2
2
  stop on stopping <%= app %>-<%= name %>
3
3
  respawn
4
4
 
5
- exec su - <%= user %> -c 'cd <%= engine.root %>; export PORT=<%= port %>;<% engine.env.each_pair do |var,env| %> export <%= var.upcase %>=<%= shell_quote(env) %>; <% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1'
5
+ env PORT=<%= port %>
6
+ <% engine.env.each do |name,value| -%>
7
+ env <%= name.upcase %>='<%= value.gsub(/'/, "'\"'\"'") %>'
8
+ <% end -%>
9
+
10
+ setuid <%= user %>
11
+
12
+ chdir <%= engine.root %>
13
+
14
+ exec <%= process.command %>
data/lib/foreman/cli.rb CHANGED
@@ -34,6 +34,7 @@ class Foreman::CLI < Thor
34
34
  end
35
35
 
36
36
  def start(process=nil)
37
+ require_posix_spawn_for_ruby_18!
37
38
  check_procfile!
38
39
  load_environment!
39
40
  engine.load_procfile(procfile)
@@ -45,6 +46,7 @@ class Foreman::CLI < Thor
45
46
 
46
47
  method_option :app, :type => :string, :aliases => "-a"
47
48
  method_option :log, :type => :string, :aliases => "-l"
49
+ method_option :run, :type => :string, :aliases => "-r", :desc => "Specify the pid file directory, defaults to /var/run/<application>"
48
50
  method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env"
49
51
  method_option :port, :type => :numeric, :aliases => "-p"
50
52
  method_option :user, :type => :string, :aliases => "-u"
@@ -137,6 +139,14 @@ private ######################################################################
137
139
  end
138
140
  end
139
141
 
142
+ def require_posix_spawn_for_ruby_18!
143
+ begin
144
+ Kernel.require 'posix/spawn' # Use Kernel explicitly so we can mock the require call in the spec
145
+ rescue LoadError
146
+ error "foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`."
147
+ end if Foreman.ruby_18?
148
+ end
149
+
140
150
  def procfile
141
151
  case
142
152
  when options[:procfile] then options[:procfile]
@@ -302,6 +302,10 @@ private
302
302
 
303
303
  def name_for(pid)
304
304
  process, index = @running[pid]
305
+ name_for_index(process, index)
306
+ end
307
+
308
+ def name_for_index(process, index)
305
309
  [ @names[process], index.to_s ].compact.join(".")
306
310
  end
307
311
 
@@ -350,7 +354,8 @@ private
350
354
  reader, writer = create_pipe
351
355
  begin
352
356
  pid = process.run(:output => writer, :env => {
353
- "PORT" => port_for(process, n).to_s
357
+ "PORT" => port_for(process, n).to_s,
358
+ "PS" => name_for_index(process, n)
354
359
  })
355
360
  writer.puts "started with pid #{pid}"
356
361
  rescue Errno::ENOENT
@@ -422,7 +427,7 @@ private
422
427
  end
423
428
  rescue Timeout::Error
424
429
  system "sending SIGKILL to all processes"
425
- killall "SIGKILL"
430
+ kill_children "SIGKILL"
426
431
  end
427
432
 
428
433
  end
@@ -28,7 +28,9 @@ end
28
28
  require "foreman/export/base"
29
29
  require "foreman/export/inittab"
30
30
  require "foreman/export/upstart"
31
+ require "foreman/export/daemon"
31
32
  require "foreman/export/bluepill"
32
33
  require "foreman/export/runit"
33
34
  require "foreman/export/supervisord"
34
35
  require "foreman/export/launchd"
36
+ require "foreman/export/systemd"
@@ -46,8 +46,8 @@ class Foreman::Export::Base
46
46
  def export
47
47
  error("Must specify a location") unless location
48
48
  FileUtils.mkdir_p(location) rescue error("Could not create: #{location}")
49
- FileUtils.mkdir_p(log) rescue error("Could not create: #{log}")
50
- FileUtils.chown(user, nil, log) rescue error("Could not chown #{log} to #{user}")
49
+ chown user, log
50
+ chown user, run
51
51
  end
52
52
 
53
53
  def app
@@ -58,6 +58,10 @@ class Foreman::Export::Base
58
58
  options[:log] || "/var/log/#{app}"
59
59
  end
60
60
 
61
+ def run
62
+ options[:run] || "/var/run/#{app}"
63
+ end
64
+
61
65
  def user
62
66
  options[:user] || app
63
67
  end
@@ -76,6 +80,12 @@ private ######################################################################
76
80
  @@deprecation_warned = true
77
81
  end
78
82
 
83
+ def chown user, dir
84
+ FileUtils.chown user, nil, dir
85
+ rescue
86
+ error("Could not chown #{dir} to #{user}") unless File.writable?(dir) || ! File.exists?(dir)
87
+ end
88
+
79
89
  def error(message)
80
90
  raise Foreman::Export::Exception.new(message)
81
91
  end
@@ -0,0 +1,28 @@
1
+ require "erb"
2
+ require "foreman/export"
3
+
4
+ class Foreman::Export::Daemon < Foreman::Export::Base
5
+
6
+ def export
7
+ super
8
+
9
+ (Dir["#{location}/#{app}-*.conf"] << "#{location}/#{app}.conf").each do |file|
10
+ clean file
11
+ end
12
+
13
+ write_template "daemon/master.conf.erb", "#{app}.conf", binding
14
+
15
+ engine.each_process do |name, process|
16
+ next if engine.formation[name] < 1
17
+ write_template "daemon/process_master.conf.erb", "#{app}-#{name}.conf", binding
18
+
19
+ 1.upto(engine.formation[name]) do |num|
20
+ port = engine.port_for(process, num)
21
+ arguments = process.command.split(" ")
22
+ executable = arguments.slice!(0)
23
+ arguments = arguments.size > 0 ? " -- #{arguments.join(' ')}" : ""
24
+ write_template "daemon/process.conf.erb", "#{app}-#{name}-#{num}.conf", binding
25
+ end
26
+ end
27
+ end
28
+ end
@@ -8,7 +8,12 @@ class Foreman::Export::Launchd < Foreman::Export::Base
8
8
  engine.each_process do |name, process|
9
9
  1.upto(engine.formation[name]) do |num|
10
10
  port = engine.port_for(process, num)
11
- command_args = process.command.split(" ")
11
+ command_args = process.command.split(/\s+/).map{|arg|
12
+ case arg
13
+ when "$PORT" then port
14
+ else arg
15
+ end
16
+ }
12
17
  write_template "launchd/launchd.plist.erb", "#{app}-#{name}-#{num}.plist", binding
13
18
  end
14
19
  end
@@ -0,0 +1,32 @@
1
+ require "erb"
2
+ require "foreman/export"
3
+
4
+ class Foreman::Export::Systemd < Foreman::Export::Base
5
+
6
+ def export
7
+ super
8
+
9
+ Dir["#{location}/#{app}*.target"].concat(Dir["#{location}/#{app}*.service"]).each do |file|
10
+ clean file
11
+ end
12
+
13
+ process_master_names = []
14
+
15
+ engine.each_process do |name, process|
16
+ next if engine.formation[name] < 1
17
+
18
+ process_names = []
19
+
20
+ 1.upto(engine.formation[name]) do |num|
21
+ port = engine.port_for(process, num)
22
+ write_template "systemd/process.service.erb", "#{app}-#{name}-#{num}.service", binding
23
+ process_names << "#{app}-#{name}-#{num}.service"
24
+ end
25
+
26
+ write_template "systemd/process_master.target.erb", "#{app}-#{name}.target", binding
27
+ process_master_names << "#{app}-#{name}.target"
28
+ end
29
+
30
+ write_template "systemd/master.target.erb", "#{app}.target", binding
31
+ end
32
+ end
@@ -1,4 +1,5 @@
1
1
  require "foreman"
2
+ require "shellwords"
2
3
 
3
4
  class Foreman::Process
4
5
 
@@ -47,25 +48,18 @@ class Foreman::Process
47
48
  def run(options={})
48
49
  env = @options[:env].merge(options[:env] || {})
49
50
  output = options[:output] || $stdout
50
-
51
+ runner = "#{Foreman.runner}".shellescape
52
+
51
53
  if Foreman.windows?
52
54
  Dir.chdir(cwd) do
53
55
  Process.spawn env, expanded_command(env), :out => output, :err => output
54
56
  end
55
- elsif Foreman.jruby_18?
57
+ elsif Foreman.jruby_18? || Foreman.ruby_18?
56
58
  require "posix/spawn"
57
- wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
58
- POSIX::Spawn.spawn env, wrapped_command, :out => output, :err => output
59
- elsif Foreman.ruby_18?
60
- fork do
61
- $stdout.reopen output
62
- $stderr.reopen output
63
- env.each { |k,v| ENV[k] = v }
64
- wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
65
- Kernel.exec wrapped_command
66
- end
59
+ wrapped_command = "#{runner} -d '#{cwd.shellescape}' -p -- #{expanded_command(env)}"
60
+ POSIX::Spawn.spawn(*spawn_args(env, wrapped_command.shellsplit, {:out => output, :err => output}))
67
61
  else
68
- wrapped_command = "#{Foreman.runner} -d '#{cwd}' -p -- #{command}"
62
+ wrapped_command = "exec #{runner} -d '#{cwd.shellescape}' -p -- #{command}"
69
63
  Process.spawn env, wrapped_command, :out => output, :err => output
70
64
  end
71
65
  end
@@ -122,4 +116,14 @@ class Foreman::Process
122
116
  File.expand_path(@options[:cwd] || ".")
123
117
  end
124
118
 
119
+ private
120
+
121
+ def spawn_args(env, argv, options)
122
+ args = []
123
+ args << env
124
+ args += argv
125
+ args << options
126
+ args
127
+ end
128
+
125
129
  end
@@ -1,5 +1,5 @@
1
1
  module Foreman
2
2
 
3
- VERSION = "0.63.0"
3
+ VERSION = "0.66.0"
4
4
 
5
5
  end
data/man/foreman.1 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "FOREMAN" "1" "January 2013" "Foreman 0.61.0" "Foreman Manual"
4
+ .TH "FOREMAN" "1" "April 2014" "Foreman 0.66.0" "Foreman Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBforeman\fR \- manage Procfile\-based applications
@@ -107,9 +107,18 @@ bluepill
107
107
  inittab
108
108
  .
109
109
  .IP "\(bu" 4
110
+ launchd
111
+ .
112
+ .IP "\(bu" 4
110
113
  runit
111
114
  .
112
115
  .IP "\(bu" 4
116
+ supervisord
117
+ .
118
+ .IP "\(bu" 4
119
+ systemd
120
+ .
121
+ .IP "\(bu" 4
113
122
  upstart
114
123
  .
115
124
  .IP "" 0
@@ -130,6 +139,18 @@ EX02:4:respawn:/bin/su \- example \-c \'PORT=5100 bundle exec rake jobs:work >>
130
139
  .
131
140
  .IP "" 0
132
141
  .
142
+ .SH "SYSTEMD EXPORT"
143
+ Will create a series of systemd scripts in the location you specify\. Scripts will be structured to make the following commands valid:
144
+ .
145
+ .P
146
+ \fBsystemctl start appname\.target\fR
147
+ .
148
+ .P
149
+ \fBsystemctl stop appname\-processname\.target\fR
150
+ .
151
+ .P
152
+ \fBsystemctl restart appname\-processname\-3\.service\fR
153
+ .
133
154
  .SH "UPSTART EXPORT"
134
155
  Will create a series of upstart scripts in the location you specify\. Scripts will be structured to make the following commands valid:
135
156
  .
@@ -157,7 +178,7 @@ job: bundle exec rake jobs:work
157
178
  .IP "" 0
158
179
  .
159
180
  .P
160
- A process name may contain letters, numbers amd the underscore character\. You can validate your Procfile format using the \fBcheck\fR command:
181
+ A process name may contain letters, numbers and the underscore character\. You can validate your Procfile format using the \fBcheck\fR command:
161
182
  .
162
183
  .IP "" 4
163
184
  .
@@ -44,6 +44,13 @@ describe "Foreman::CLI", :fakefs do
44
44
  output.should =~ /test.1 \| testing/
45
45
  end
46
46
  end
47
+
48
+ it "sets PS variable with the process name" do
49
+ without_fakefs do
50
+ output = foreman("start -f #{resource_path("Procfile")}")
51
+ output.should =~ /ps.1 \| PS env var is ps.1/
52
+ end
53
+ end
47
54
  end
48
55
  end
49
56
 
@@ -93,4 +100,12 @@ describe "Foreman::CLI", :fakefs do
93
100
  end
94
101
  end
95
102
 
103
+ describe "when posix-spawn is not present on ruby 1.8" do
104
+ it "should fail with an error" do
105
+ mock(Kernel).require('posix/spawn') { raise LoadError }
106
+ output = foreman("start -f #{resource_path("Procfile")}")
107
+ output.should == "ERROR: foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`.\n"
108
+ end
109
+ end if running_ruby_18?
110
+
96
111
  end
@@ -0,0 +1,97 @@
1
+ require "spec_helper"
2
+ require "foreman/engine"
3
+ require "foreman/export/daemon"
4
+ require "tmpdir"
5
+
6
+ describe Foreman::Export::Daemon, :fakefs do
7
+ let(:procfile) { write_procfile("/tmp/app/Procfile") }
8
+ let(:formation) { nil }
9
+ let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
10
+ let(:options) { Hash.new }
11
+ let(:daemon) { Foreman::Export::Daemon.new("/tmp/init", engine, options) }
12
+
13
+ before(:each) { load_export_templates_into_fakefs("daemon") }
14
+ before(:each) { stub(daemon).say }
15
+
16
+ it "exports to the filesystem" do
17
+ daemon.export
18
+
19
+ File.read("/tmp/init/app.conf").should == example_export_file("daemon/app.conf")
20
+ File.read("/tmp/init/app-alpha.conf").should == example_export_file("daemon/app-alpha.conf")
21
+ File.read("/tmp/init/app-alpha-1.conf").should == example_export_file("daemon/app-alpha-1.conf")
22
+ File.read("/tmp/init/app-bravo.conf").should == example_export_file("daemon/app-bravo.conf")
23
+ File.read("/tmp/init/app-bravo-1.conf").should == example_export_file("daemon/app-bravo-1.conf")
24
+ end
25
+
26
+ it "cleans up if exporting into an existing dir" do
27
+ mock(FileUtils).rm("/tmp/init/app.conf")
28
+ mock(FileUtils).rm("/tmp/init/app-alpha.conf")
29
+ mock(FileUtils).rm("/tmp/init/app-alpha-1.conf")
30
+ mock(FileUtils).rm("/tmp/init/app-bravo.conf")
31
+ mock(FileUtils).rm("/tmp/init/app-bravo-1.conf")
32
+ mock(FileUtils).rm("/tmp/init/app-foo-bar.conf")
33
+ mock(FileUtils).rm("/tmp/init/app-foo-bar-1.conf")
34
+ mock(FileUtils).rm("/tmp/init/app-foo_bar.conf")
35
+ mock(FileUtils).rm("/tmp/init/app-foo_bar-1.conf")
36
+
37
+ daemon.export
38
+ daemon.export
39
+ end
40
+
41
+ it "does not delete exported files for similarly named applications" do
42
+ FileUtils.mkdir_p "/tmp/init"
43
+
44
+ ["app2", "app2-alpha", "app2-alpha-1"].each do |name|
45
+ path = "/tmp/init/#{name}.conf"
46
+ FileUtils.touch(path)
47
+ dont_allow(FileUtils).rm(path)
48
+ end
49
+
50
+ daemon.export
51
+ end
52
+
53
+ context "with a formation" do
54
+ let(:formation) { "alpha=2" }
55
+
56
+ it "exports to the filesystem with concurrency" do
57
+ daemon.export
58
+
59
+ File.read("/tmp/init/app.conf").should == example_export_file("daemon/app.conf")
60
+ File.read("/tmp/init/app-alpha.conf").should == example_export_file("daemon/app-alpha.conf")
61
+ File.read("/tmp/init/app-alpha-1.conf").should == example_export_file("daemon/app-alpha-1.conf")
62
+ File.read("/tmp/init/app-alpha-2.conf").should == example_export_file("daemon/app-alpha-2.conf")
63
+ File.exists?("/tmp/init/app-bravo-1.conf").should == false
64
+ end
65
+ end
66
+
67
+ context "with alternate templates" do
68
+ let(:template) { "/tmp/alternate" }
69
+ let(:options) { { :app => "app", :template => template } }
70
+
71
+ before do
72
+ FileUtils.mkdir_p template
73
+ File.open("#{template}/master.conf.erb", "w") { |f| f.puts "alternate_template" }
74
+ end
75
+
76
+ it "can export with alternate template files" do
77
+ daemon.export
78
+ File.read("/tmp/init/app.conf").should == "alternate_template\n"
79
+ end
80
+ end
81
+
82
+ context "with alternate templates from home dir" do
83
+
84
+ before do
85
+ FileUtils.mkdir_p File.expand_path("~/.foreman/templates/daemon")
86
+ File.open(File.expand_path("~/.foreman/templates/daemon/master.conf.erb"), "w") do |file|
87
+ file.puts "default_alternate_template"
88
+ end
89
+ end
90
+
91
+ it "can export with alternate template files" do
92
+ daemon.export
93
+ File.read("/tmp/init/app.conf").should == "default_alternate_template\n"
94
+ end
95
+ end
96
+
97
+ end
@@ -0,0 +1,91 @@
1
+ require "spec_helper"
2
+ require "foreman/engine"
3
+ require "foreman/export/systemd"
4
+ require "tmpdir"
5
+
6
+ describe Foreman::Export::Systemd, :fakefs do
7
+ let(:procfile) { write_procfile("/tmp/app/Procfile") }
8
+ let(:formation) { nil }
9
+ let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
10
+ let(:options) { Hash.new }
11
+ let(:systemd) { Foreman::Export::Systemd.new("/tmp/init", engine, options) }
12
+
13
+ before(:each) { load_export_templates_into_fakefs("systemd") }
14
+ before(:each) { stub(systemd).say }
15
+
16
+ it "exports to the filesystem" do
17
+ systemd.export
18
+
19
+ File.read("/tmp/init/app.target").should == example_export_file("systemd/app.target")
20
+ File.read("/tmp/init/app-alpha.target").should == example_export_file("systemd/app-alpha.target")
21
+ File.read("/tmp/init/app-alpha-1.service").should == example_export_file("systemd/app-alpha-1.service")
22
+ File.read("/tmp/init/app-bravo.target").should == example_export_file("systemd/app-bravo.target")
23
+ File.read("/tmp/init/app-bravo-1.service").should == example_export_file("systemd/app-bravo-1.service")
24
+ end
25
+
26
+ it "cleans up if exporting into an existing dir" do
27
+ mock(FileUtils).rm("/tmp/init/app.target")
28
+ mock(FileUtils).rm("/tmp/init/app-alpha.target")
29
+ mock(FileUtils).rm("/tmp/init/app-alpha-1.service")
30
+ mock(FileUtils).rm("/tmp/init/app-bravo.target")
31
+ mock(FileUtils).rm("/tmp/init/app-bravo-1.service")
32
+ mock(FileUtils).rm("/tmp/init/app-foo-bar.target")
33
+ mock(FileUtils).rm("/tmp/init/app-foo-bar-1.service")
34
+ mock(FileUtils).rm("/tmp/init/app-foo_bar.target")
35
+ mock(FileUtils).rm("/tmp/init/app-foo_bar-1.service")
36
+
37
+ systemd.export
38
+ systemd.export
39
+ end
40
+
41
+ it "includes environment variables" do
42
+ engine.env['KEY'] = 'some "value"'
43
+ systemd.export
44
+ File.read("/tmp/init/app-alpha-1.service").should =~ /KEY=some "value"$/
45
+ end
46
+
47
+ context "with a formation" do
48
+ let(:formation) { "alpha=2" }
49
+
50
+ it "exports to the filesystem with concurrency" do
51
+ systemd.export
52
+
53
+ File.read("/tmp/init/app.target").should == example_export_file("systemd/app.target")
54
+ File.read("/tmp/init/app-alpha.target").should == example_export_file("systemd/app-alpha.target")
55
+ File.read("/tmp/init/app-alpha-1.service").should == example_export_file("systemd/app-alpha-1.service")
56
+ File.read("/tmp/init/app-alpha-2.service").should == example_export_file("systemd/app-alpha-2.service")
57
+ File.exists?("/tmp/init/app-bravo-1.service").should == false
58
+ end
59
+ end
60
+
61
+ context "with alternate templates" do
62
+ let(:template) { "/tmp/alternate" }
63
+ let(:options) { { :app => "app", :template => template } }
64
+
65
+ before do
66
+ FileUtils.mkdir_p template
67
+ File.open("#{template}/master.target.erb", "w") { |f| f.puts "alternate_template" }
68
+ end
69
+
70
+ it "can export with alternate template files" do
71
+ systemd.export
72
+ File.read("/tmp/init/app.target").should == "alternate_template\n"
73
+ end
74
+ end
75
+
76
+ context "with alternate templates from home dir" do
77
+
78
+ before do
79
+ FileUtils.mkdir_p File.expand_path("~/.foreman/templates/systemd")
80
+ File.open(File.expand_path("~/.foreman/templates/systemd/master.target.erb"), "w") do |file|
81
+ file.puts "default_alternate_template"
82
+ end
83
+ end
84
+
85
+ it "can export with alternate template files" do
86
+ systemd.export
87
+ File.read("/tmp/init/app.target").should == "default_alternate_template\n"
88
+ end
89
+ end
90
+
91
+ end
@@ -41,7 +41,7 @@ describe Foreman::Process do
41
41
 
42
42
  it "should output utf8 properly" do
43
43
  process = Foreman::Process.new(resource_path("bin/utf8"))
44
- run(process).should == "\xFF\x03\n".force_encoding('binary')
44
+ run(process).should == (Foreman.ruby_18? ? "\xFF\x03\n" : "\xFF\x03\n".force_encoding('binary'))
45
45
  end
46
46
  end
47
47
 
@@ -2,3 +2,4 @@ echo: bin/echo echoing
2
2
  env: bin/env FOO
3
3
  test: bin/test
4
4
  utf8: bin/utf8
5
+ ps: bin/echo PS env var is $PS
@@ -0,0 +1,7 @@
1
+ start on starting app-alpha
2
+ stop on stopping app-alpha
3
+ respawn
4
+
5
+ env PORT=5000
6
+
7
+ exec start-stop-daemon --start --chuid app --chdir /tmp/app --make-pidfile --pidfile /var/run/app/app-alpha-1.pid --exec ./alpha >> /var/log/app/app-alpha-1.log 2>&1
@@ -0,0 +1,7 @@
1
+ start on starting app-alpha
2
+ stop on stopping app-alpha
3
+ respawn
4
+
5
+ env PORT=5001
6
+
7
+ exec start-stop-daemon --start --chuid app --chdir /tmp/app --make-pidfile --pidfile /var/run/app/app-alpha-2.pid --exec ./alpha >> /var/log/app/app-alpha-2.log 2>&1
@@ -0,0 +1,2 @@
1
+ start on starting app
2
+ stop on stopping app
@@ -0,0 +1,7 @@
1
+ start on starting app-bravo
2
+ stop on stopping app-bravo
3
+ respawn
4
+
5
+ env PORT=5100
6
+
7
+ exec start-stop-daemon --start --chuid app --chdir /tmp/app --make-pidfile --pidfile /var/run/app/app-bravo-1.pid --exec ./bravo >> /var/log/app/app-bravo-1.log 2>&1
@@ -0,0 +1,2 @@
1
+ start on starting app
2
+ stop on stopping app
@@ -0,0 +1,14 @@
1
+ pre-start script
2
+
3
+ bash << "EOF"
4
+ mkdir -p /var/log/app
5
+ chown -R app /var/log/app
6
+ mkdir -p /var/run/app
7
+ chown -R app /var/run/app
8
+ EOF
9
+
10
+ end script
11
+
12
+ start on runlevel [2345]
13
+
14
+ stop on runlevel [016]
@@ -3,5 +3,5 @@ set -e
3
3
 
4
4
  LOG=/var/log/app/alpha-1
5
5
 
6
- test -d "$LOG" || mkdir -p m2750 "$LOG" && chown app "$LOG"
6
+ test -d "$LOG" || mkdir -p -m 2750 "$LOG" && chown app "$LOG"
7
7
  exec chpst -u app svlogd "$LOG"
@@ -3,5 +3,5 @@ set -e
3
3
 
4
4
  LOG=/var/log/app/alpha-2
5
5
 
6
- test -d "$LOG" || mkdir -p m2750 "$LOG" && chown app "$LOG"
6
+ test -d "$LOG" || mkdir -p -m 2750 "$LOG" && chown app "$LOG"
7
7
  exec chpst -u app svlogd "$LOG"
@@ -3,5 +3,5 @@ set -e
3
3
 
4
4
  LOG=/var/log/app/bravo-1
5
5
 
6
- test -d "$LOG" || mkdir -p m2750 "$LOG" && chown app "$LOG"
6
+ test -d "$LOG" || mkdir -p -m 2750 "$LOG" && chown app "$LOG"
7
7
  exec chpst -u app svlogd "$LOG"
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log
8
8
  stderr_logfile=/var/log/app/alpha-1.error.log
9
9
  user=app
10
10
  directory=/tmp/app
11
- environment=PORT=5000
11
+ environment=PORT="5000"
12
12
  [program:app-bravo-1]
13
13
  command=./bravo
14
14
  autostart=true
@@ -18,7 +18,7 @@ stdout_logfile=/var/log/app/bravo-1.log
18
18
  stderr_logfile=/var/log/app/bravo-1.error.log
19
19
  user=app
20
20
  directory=/tmp/app
21
- environment=PORT=5100
21
+ environment=PORT="5100"
22
22
  [program:app-foo_bar-1]
23
23
  command=./foo_bar
24
24
  autostart=true
@@ -28,7 +28,7 @@ stdout_logfile=/var/log/app/foo_bar-1.log
28
28
  stderr_logfile=/var/log/app/foo_bar-1.error.log
29
29
  user=app
30
30
  directory=/tmp/app
31
- environment=PORT=5200
31
+ environment=PORT="5200"
32
32
  [program:app-foo-bar-1]
33
33
  command=./foo-bar
34
34
  autostart=true
@@ -38,7 +38,7 @@ stdout_logfile=/var/log/app/foo-bar-1.log
38
38
  stderr_logfile=/var/log/app/foo-bar-1.error.log
39
39
  user=app
40
40
  directory=/tmp/app
41
- environment=PORT=5300
41
+ environment=PORT="5300"
42
42
 
43
43
  [group:app]
44
44
  programs=app-alpha-1,app-bravo-1,app-foo_bar-1,app-foo-bar-1
@@ -8,7 +8,7 @@ stdout_logfile=/var/log/app/alpha-1.log
8
8
  stderr_logfile=/var/log/app/alpha-1.error.log
9
9
  user=app
10
10
  directory=/tmp/app
11
- environment=PORT=5000
11
+ environment=PORT="5000"
12
12
  [program:app-alpha-2]
13
13
  command=./alpha
14
14
  autostart=true
@@ -18,7 +18,7 @@ stdout_logfile=/var/log/app/alpha-2.log
18
18
  stderr_logfile=/var/log/app/alpha-2.error.log
19
19
  user=app
20
20
  directory=/tmp/app
21
- environment=PORT=5001
21
+ environment=PORT="5001"
22
22
 
23
23
  [group:app]
24
24
  programs=app-alpha-1,app-alpha-2
@@ -0,0 +1,17 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+
4
+ [Service]
5
+ User=app
6
+ WorkingDirectory=/tmp/app
7
+ Environment=PORT=5000
8
+ ExecStart=/bin/bash -lc './alpha'
9
+ Restart=always
10
+ StandardInput=null
11
+ StandardOutput=syslog
12
+ StandardError=syslog
13
+ SyslogIdentifier=%n
14
+ KillMode=process
15
+
16
+ [Install]
17
+ WantedBy=app-alpha.target
@@ -0,0 +1,17 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+
4
+ [Service]
5
+ User=app
6
+ WorkingDirectory=/tmp/app
7
+ Environment=PORT=5001
8
+ ExecStart=/bin/bash -lc './alpha'
9
+ Restart=always
10
+ StandardInput=null
11
+ StandardOutput=syslog
12
+ StandardError=syslog
13
+ SyslogIdentifier=%n
14
+ KillMode=process
15
+
16
+ [Install]
17
+ WantedBy=app-alpha.target
@@ -0,0 +1,5 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+
4
+ [Install]
5
+ WantedBy=app.target
@@ -0,0 +1,17 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+
4
+ [Service]
5
+ User=app
6
+ WorkingDirectory=/tmp/app
7
+ Environment=PORT=5100
8
+ ExecStart=/bin/bash -lc './bravo'
9
+ Restart=always
10
+ StandardInput=null
11
+ StandardOutput=syslog
12
+ StandardError=syslog
13
+ SyslogIdentifier=%n
14
+ KillMode=process
15
+
16
+ [Install]
17
+ WantedBy=app-bravo.target
@@ -0,0 +1,5 @@
1
+ [Unit]
2
+ StopWhenUnneeded=true
3
+
4
+ [Install]
5
+ WantedBy=app.target
@@ -0,0 +1 @@
1
+ [Unit]
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,15 @@ require "fakefs/spec_helpers"
10
10
 
11
11
  $:.unshift File.expand_path("../../lib", __FILE__)
12
12
 
13
+ begin
14
+ def running_ruby_18?
15
+ defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
16
+ end
17
+ require 'posix/spawn' if running_ruby_18?
18
+ rescue LoadError
19
+ STDERR.puts "WARNING: foreman requires gem `posix-spawn` on Ruby #{RUBY_VERSION}. Please `gem install posix-spawn`."
20
+ end
21
+
13
22
  def mock_export_error(message)
14
23
  lambda { yield }.should raise_error(Foreman::Export::Exception, message)
15
24
  end
@@ -21,6 +30,10 @@ def mock_error(subject, message)
21
30
  end
22
31
  end
23
32
 
33
+ def make_pipe
34
+ IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
35
+ end
36
+
24
37
  def foreman(args)
25
38
  capture_stdout do
26
39
  begin
@@ -31,14 +44,18 @@ def foreman(args)
31
44
  end
32
45
 
33
46
  def forked_foreman(args)
34
- rd, wr = IO.pipe("BINARY")
35
- Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
47
+ rd, wr = make_pipe
48
+ if running_ruby_18?
49
+ POSIX::Spawn.spawn({}, "bundle exec bin/foreman #{args}", :out => wr, :err => wr)
50
+ else
51
+ Process.spawn("bundle exec bin/foreman #{args}", :out => wr, :err => wr)
52
+ end
36
53
  wr.close
37
54
  rd.read
38
55
  end
39
56
 
40
57
  def fork_and_capture(&blk)
41
- rd, wr = IO.pipe("BINARY")
58
+ rd, wr = make_pipe
42
59
  pid = fork do
43
60
  rd.close
44
61
  wr.sync = true
@@ -57,7 +74,11 @@ def fork_and_capture(&blk)
57
74
  end
58
75
 
59
76
  def fork_and_get_exitstatus(args)
60
- pid = Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
77
+ pid = if running_ruby_18?
78
+ POSIX::Spawn.spawn({}, "bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
79
+ else
80
+ Process.spawn("bundle exec bin/foreman #{args}", :out => "/dev/null", :err => "/dev/null")
81
+ end
61
82
  Process.wait(pid)
62
83
  $?.exitstatus
63
84
  end
@@ -141,7 +162,7 @@ end
141
162
 
142
163
  def capture_stdout
143
164
  old_stdout = $stdout.dup
144
- rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
165
+ rd, wr = make_pipe
145
166
  $stdout = wr
146
167
  yield
147
168
  wr.close
@@ -156,4 +177,5 @@ RSpec.configure do |config|
156
177
  config.order = 'rand'
157
178
  config.include FakeFS::SpecHelpers, :fakefs
158
179
  config.mock_with :rr
180
+ config.backtrace_clean_patterns = []
159
181
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.0
4
+ version: 0.66.0
5
5
  prerelease:
6
6
  platform: mingw32
7
7
  authors:
@@ -9,33 +9,43 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-15 00:00:00.000000000 Z
12
+ date: 2014-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70250516346600 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.13.6
21
+ version: 0.19.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70250516346600
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.19.1
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: dotenv
27
- requirement: &70250516341680 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
- - - ! '>='
35
+ - - ~>
31
36
  - !ruby/object:Gem::Version
32
- version: '0.7'
37
+ version: 0.7.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70250516341680
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.7.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: win32console
38
- requirement: &70250516354100 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: 1.3.0
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70250516354100
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.0
47
62
  description: Process manager for applications with multiple components
48
63
  email: ddollar@gmail.com
49
64
  executables:
@@ -53,7 +68,6 @@ extra_rdoc_files: []
53
68
  files:
54
69
  - bin/foreman
55
70
  - bin/foreman-runner
56
- - bin/taskman
57
71
  - data/example/error
58
72
  - data/example/log/neverdie.log
59
73
  - data/example/Procfile
@@ -63,24 +77,31 @@ files:
63
77
  - data/example/ticker
64
78
  - data/example/utf8
65
79
  - data/export/bluepill/master.pill.erb
80
+ - data/export/daemon/master.conf.erb
81
+ - data/export/daemon/process.conf.erb
82
+ - data/export/daemon/process_master.conf.erb
66
83
  - data/export/launchd/launchd.plist.erb
67
84
  - data/export/runit/log/run.erb
68
85
  - data/export/runit/run.erb
69
86
  - data/export/supervisord/app.conf.erb
87
+ - data/export/systemd/master.target.erb
88
+ - data/export/systemd/process.service.erb
89
+ - data/export/systemd/process_master.target.erb
70
90
  - data/export/upstart/master.conf.erb
71
91
  - data/export/upstart/process.conf.erb
72
92
  - data/export/upstart/process_master.conf.erb
73
- - lib/foreman/capistrano.rb
74
93
  - lib/foreman/cli.rb
75
94
  - lib/foreman/distribution.rb
76
95
  - lib/foreman/engine/cli.rb
77
96
  - lib/foreman/engine.rb
78
97
  - lib/foreman/export/base.rb
79
98
  - lib/foreman/export/bluepill.rb
99
+ - lib/foreman/export/daemon.rb
80
100
  - lib/foreman/export/inittab.rb
81
101
  - lib/foreman/export/launchd.rb
82
102
  - lib/foreman/export/runit.rb
83
103
  - lib/foreman/export/supervisord.rb
104
+ - lib/foreman/export/systemd.rb
84
105
  - lib/foreman/export/upstart.rb
85
106
  - lib/foreman/export.rb
86
107
  - lib/foreman/helpers.rb
@@ -93,10 +114,12 @@ files:
93
114
  - spec/foreman/engine_spec.rb
94
115
  - spec/foreman/export/base_spec.rb
95
116
  - spec/foreman/export/bluepill_spec.rb
117
+ - spec/foreman/export/daemon_spec.rb
96
118
  - spec/foreman/export/inittab_spec.rb
97
119
  - spec/foreman/export/launchd_spec.rb
98
120
  - spec/foreman/export/runit_spec.rb
99
121
  - spec/foreman/export/supervisord_spec.rb
122
+ - spec/foreman/export/systemd_spec.rb
100
123
  - spec/foreman/export/upstart_spec.rb
101
124
  - spec/foreman/export_spec.rb
102
125
  - spec/foreman/helpers_spec.rb
@@ -110,6 +133,12 @@ files:
110
133
  - spec/resources/bin/utf8
111
134
  - spec/resources/export/bluepill/app-concurrency.pill
112
135
  - spec/resources/export/bluepill/app.pill
136
+ - spec/resources/export/daemon/app-alpha-1.conf
137
+ - spec/resources/export/daemon/app-alpha-2.conf
138
+ - spec/resources/export/daemon/app-alpha.conf
139
+ - spec/resources/export/daemon/app-bravo-1.conf
140
+ - spec/resources/export/daemon/app-bravo.conf
141
+ - spec/resources/export/daemon/app.conf
113
142
  - spec/resources/export/inittab/inittab.concurrency
114
143
  - spec/resources/export/inittab/inittab.default
115
144
  - spec/resources/export/launchd/launchd-a.default
@@ -123,6 +152,12 @@ files:
123
152
  - spec/resources/export/runit/app-bravo-1/run
124
153
  - spec/resources/export/supervisord/app-alpha-1.conf
125
154
  - spec/resources/export/supervisord/app-alpha-2.conf
155
+ - spec/resources/export/systemd/app-alpha-1.service
156
+ - spec/resources/export/systemd/app-alpha-2.service
157
+ - spec/resources/export/systemd/app-alpha.target
158
+ - spec/resources/export/systemd/app-bravo-1.service
159
+ - spec/resources/export/systemd/app-bravo.target
160
+ - spec/resources/export/systemd/app.target
126
161
  - spec/resources/export/upstart/app-alpha-1.conf
127
162
  - spec/resources/export/upstart/app-alpha-2.conf
128
163
  - spec/resources/export/upstart/app-alpha.conf
@@ -153,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
188
  version: '0'
154
189
  requirements: []
155
190
  rubyforge_project:
156
- rubygems_version: 1.8.11
191
+ rubygems_version: 1.8.23
157
192
  signing_key:
158
193
  specification_version: 3
159
194
  summary: Process manager for applications with multiple components
data/bin/taskman DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $:.unshift File.expand_path("../../lib", __FILE__)
4
-
5
- require "foreman/cli"
6
-
7
- Foreman::CLI.engine_class = Foreman::TmuxEngine
8
- Foreman::CLI.start
@@ -1,54 +0,0 @@
1
- if defined?(Capistrano)
2
- Capistrano::Configuration.instance(:must_exist).load do
3
-
4
- namespace :foreman do
5
- desc <<-DESC
6
- Export the Procfile to upstart. Will use sudo if available.
7
-
8
- You can override any of these defaults by setting the variables shown below.
9
-
10
- set :foreman_format, "upstart"
11
- set :foreman_location, "/etc/init"
12
- set :foreman_procfile, "Procfile"
13
- set :foreman_app, application
14
- set :foreman_user, user
15
- set :foreman_log, 'shared_path/log'
16
- set :foreman_concurrency, false
17
- DESC
18
- task :export, :roles => :app do
19
- bundle_cmd = fetch(:bundle_cmd, "bundle")
20
- foreman_format = fetch(:foreman_format, "upstart")
21
- foreman_location = fetch(:foreman_location, "/etc/init")
22
- foreman_procfile = fetch(:foreman_procfile, "Procfile")
23
- foreman_app = fetch(:foreman_app, application)
24
- foreman_user = fetch(:foreman_user, user)
25
- foreman_log = fetch(:foreman_log, "#{shared_path}/log")
26
- foreman_concurrency = fetch(:foreman_concurrency, false)
27
-
28
- args = ["#{foreman_format} #{foreman_location}"]
29
- args << "-f #{foreman_procfile}"
30
- args << "-a #{foreman_app}"
31
- args << "-u #{foreman_user}"
32
- args << "-l #{foreman_log}"
33
- args << "-c #{foreman_concurrency}" if foreman_concurrency
34
- run "cd #{release_path} && #{sudo} #{bundle_cmd} exec foreman export #{args.join(' ')}"
35
- end
36
-
37
- desc "Start the application services"
38
- task :start, :roles => :app do
39
- run "#{sudo} start #{application}"
40
- end
41
-
42
- desc "Stop the application services"
43
- task :stop, :roles => :app do
44
- run "#{sudo} stop #{application}"
45
- end
46
-
47
- desc "Restart the application services"
48
- task :restart, :roles => :app do
49
- run "#{sudo} start #{application} || #{sudo} restart #{application}"
50
- end
51
-
52
- end
53
- end
54
- end