inittab export
This commit is contained in:
1 parent
fd3dc590d9
commit
adb40881d7
3 files changed
+33
No files matched your search
@@ -34,6 +34,7 @@ class Foreman::CLI < Thor
|
|||||||
|
|
||||||
formatter = case format
|
formatter = case format
|
||||||
when "upstart" then Foreman::Export::Upstart
|
when "upstart" then Foreman::Export::Upstart
|
||||||
|
when "inittab" then Foreman::Export::Inittab
|
||||||
else error "Unknown export format: #{format}."
|
else error "Unknown export format: #{format}."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ module Foreman::Export
|
|||||||
end
|
end
|
||||||
|
|
||||||
require "foreman/export/upstart"
|
require "foreman/export/upstart"
|
||||||
|
require "foreman/export/inittab"
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
require "foreman/export/base"
|
||||||
|
|
||||||
|
class Foreman::Export::Inittab < Foreman::Export::Base
|
||||||
|
|
||||||
|
def export(fname=nil, options={})
|
||||||
|
app = options[:app] || File.basename(engine.directory)
|
||||||
|
user = options[:user] || app
|
||||||
|
log_dir = "/var/log/#{app}"
|
||||||
|
|
||||||
|
concurrency = parse_concurrency(options[:concurrency])
|
||||||
|
|
||||||
|
inittab = []
|
||||||
|
inittab << "# ----- foreman #{app} processes -----"
|
||||||
|
engine.processes.values.each_with_index do |process, num|
|
||||||
|
id = app.slice(0, 2).upcase + sprintf("%02d", num+1)
|
||||||
|
inittab << "#{id}:4:respawn:/bin/su - #{user} -c '#{process.command} >> #{log_dir}/#{process.name}-#{num+1}.log 2>&1'"
|
||||||
|
end
|
||||||
|
inittab << "# ----- end foreman #{app} processes -----"
|
||||||
|
|
||||||
|
inittab = inittab.join("\n") + "\n"
|
||||||
|
|
||||||
|
if fname
|
||||||
|
FileUtils.mkdir_p(log_dir)
|
||||||
|
FileUtils.chown(user, nil, log_dir)
|
||||||
|
write_file(fname, inittab)
|
||||||
|
else
|
||||||
|
puts inittab
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in new issue
Block a user