restructure init files, add optional --user flag for export

This commit is contained in:
David Dollar
2010-06-28 22:52:44 -04:00
parent 426241d461
commit 10e572de94
6 changed files with 16 additions and 9 deletions
-6
View File
@@ -2,12 +2,6 @@ pre-start script
bash << "EOF"
mkdir -p /var/log/<%= app %>
<% engine.processes.keys.sort.each do |process| %>
<% 1.upto(concurrency[process]).each do |num| %>
start <%=app%>-<%=process%>-<%=num%>
<% end %>
<% end %>
EOF
end script
+3 -2
View File
@@ -1,5 +1,6 @@
stop on stopping <%= app %>
start on starting <%= app %>-<%= process.name %>
stop on stopping <%= app %>-<%= process.name %>
respawn
chdir <%= engine.directory %>
exec <%= process.command %> >> /var/log/<%=app%>/<%=process.name%>-<%=num%>.log 2>&1
exec sudo -u <%= user %> <%= process.command %> >> /var/log/<%=app%>/<%=process.name%>-<%=num%>.log 2>&1
+2
View File
@@ -0,0 +1,2 @@
start on starting <%= app %>
stop on stopping <%= app %>
+2 -1
View File
@@ -26,9 +26,9 @@ class Foreman::CLI < Thor
desc "export FORMAT LOCATION", "Export the application to another process management format"
method_option :app, :type => :string, :aliases => "-a"
method_option :user, :type => :string, :aliases => "-u"
method_option :concurrency, :type => :string, :aliases => "-c",
:banner => '"alpha=5,bar=3"'
def export(format, location=nil)
check_procfile!
@@ -39,6 +39,7 @@ class Foreman::CLI < Thor
formatter.new(engine).export(location,
:name => options[:app],
:user => options[:user],
:concurrency => options[:concurrency]
)
rescue Foreman::Export::Exception => ex
+5
View File
@@ -9,6 +9,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
FileUtils.mkdir_p location
app = options[:app] || File.basename(engine.directory)
user = options[:user] || app
Dir["#{location}/#{app}*.conf"].each do |file|
say "cleaning up: #{file}"
@@ -24,6 +25,10 @@ class Foreman::Export::Upstart < Foreman::Export::Base
process_template = export_template("upstart/process.conf.erb")
engine.processes.values.each do |process|
process_master_template = export_template("upstart/process_master.conf.erb")
process_master_config = ERB.new(process_master_template).result(binding)
write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
1.upto(concurrency[process.name]) do |num|
process_config = ERB.new(process_template).result(binding)
write_file "#{location}/#{app}-#{process.name}-#{num}.conf", process_config
+4
View File
@@ -47,6 +47,10 @@ The following options control how the application is run:
Specify the number of each process type to run. The value passed in
should be in the format `process=num,process=num`
* `-u`, `--user`:
Specify the user the application should be run as. Defaults to the
app name
## OPTIONS
These options control all modes of foreman's operation.