Added start-stop-daemon support.
This commit is contained in:
@@ -45,6 +45,7 @@ class Foreman::CLI < Thor
|
||||
|
||||
method_option :app, :type => :string, :aliases => "-a"
|
||||
method_option :log, :type => :string, :aliases => "-l"
|
||||
method_option :run, :type => :string, :aliases => "-r", :desc => "Specify the pid file directory, defaults to /var/run/<application>"
|
||||
method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env"
|
||||
method_option :port, :type => :numeric, :aliases => "-p"
|
||||
method_option :user, :type => :string, :aliases => "-u"
|
||||
|
||||
@@ -28,6 +28,7 @@ end
|
||||
require "foreman/export/base"
|
||||
require "foreman/export/inittab"
|
||||
require "foreman/export/upstart"
|
||||
require "foreman/export/daemon"
|
||||
require "foreman/export/bluepill"
|
||||
require "foreman/export/runit"
|
||||
require "foreman/export/supervisord"
|
||||
|
||||
@@ -47,7 +47,9 @@ class Foreman::Export::Base
|
||||
error("Must specify a location") unless location
|
||||
FileUtils.mkdir_p(location) rescue error("Could not create: #{location}")
|
||||
FileUtils.mkdir_p(log) rescue error("Could not create: #{log}")
|
||||
FileUtils.mkdir_p(run) rescue error("Could not create: #{run}")
|
||||
FileUtils.chown(user, nil, log) rescue error("Could not chown #{log} to #{user}")
|
||||
FileUtils.chown(user, nil, run) rescue error("Could not chown #{run} to #{user}")
|
||||
end
|
||||
|
||||
def app
|
||||
@@ -58,6 +60,10 @@ class Foreman::Export::Base
|
||||
options[:log] || "/var/log/#{app}"
|
||||
end
|
||||
|
||||
def run
|
||||
options[:run] || "/var/run/#{app}"
|
||||
end
|
||||
|
||||
def user
|
||||
options[:user] || app
|
||||
end
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
require "erb"
|
||||
require "foreman/export"
|
||||
|
||||
class Foreman::Export::Daemon < Foreman::Export::Base
|
||||
|
||||
def export
|
||||
super
|
||||
|
||||
(Dir["#{location}/#{app}-*.conf"] << "#{location}/#{app}.conf").each do |file|
|
||||
clean file
|
||||
end
|
||||
|
||||
write_template "daemon/master.conf.erb", "#{app}.conf", binding
|
||||
|
||||
engine.each_process do |name, process|
|
||||
next if engine.formation[name] < 1
|
||||
write_template "daemon/process_master.conf.erb", "#{app}-#{name}.conf", binding
|
||||
|
||||
1.upto(engine.formation[name]) do |num|
|
||||
port = engine.port_for(process, num)
|
||||
arguments = process.command.split(" ")
|
||||
executable = arguments.slice!(0)
|
||||
arguments = arguments.size > 0 ? " -- #{arguments.join(' ')}" : ""
|
||||
write_template "daemon/process.conf.erb", "#{app}-#{name}-#{num}.conf", binding
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user