Fixed a few bugs.
This commit is contained in:
parent
9c6cd80630
commit
3007c047e7
@ -42,13 +42,13 @@ do_start()
|
|||||||
mkdir -p <%= log %>
|
mkdir -p <%= log %>
|
||||||
chown $USERNAME: <%= log %>
|
chown $USERNAME: <%= log %>
|
||||||
# START APPLICATION: <%= app %>
|
# START APPLICATION: <%= app %>
|
||||||
<% engine.procfile.entries.each do |process| %>
|
<% engine.each_process do |name, process| %>
|
||||||
# START PROCESS: <%= process.name %>
|
# START PROCESS: <%= name %>
|
||||||
<% 1.upto(concurrency[process.name]) do |num| %>
|
<% 1.upto(engine.formation[name]) do |num| %>
|
||||||
# START CONCURRENT: <%= num %>
|
# START CONCURRENT: <%= num %>
|
||||||
# Start: <%= app %>.<%= process.name %>.<%= num %>
|
# Start: <%= app %>.<%= name %>.<%= num %>
|
||||||
# Create $PIDDIR/<%= process.name %>.<%= num %>.pid
|
# Create $PIDDIR/<%= name %>.<%= num %>.pid
|
||||||
su - $USERNAME -c 'cd <%= engine.directory %>; export PORT=<%= engine.port_for(process, num, self.port) %>;<% engine.environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= env %>; <% end %> <%= process.command %> >> <%= log %>/<%=process.name%>-<%=num%>.log 2>&1 & echo $!' > $PIDDIR/<%= process.name %>.<%= num %>.pid
|
su - $USERNAME -c 'cd <%= engine.root %>; export PORT=<%= engine.port_for(process, num) %>;<% engine.environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= env %>; <% end %> <%= process.command %> >> <%= log %>/<%=name%>-<%=num%>.log 2>&1 & echo $!' > $PIDDIR/<%= name %>.<%= num %>.pid
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@ -60,13 +60,13 @@ do_start()
|
|||||||
do_stop()
|
do_stop()
|
||||||
{
|
{
|
||||||
# STOP APPLICATION: <%= app %>
|
# STOP APPLICATION: <%= app %>
|
||||||
<% engine.procfile.entries.each do |process| %>
|
<% engine.each_process do |name, process| %>
|
||||||
# STOP PROCESS: <%= process.name %>
|
# STOP PROCESS: <%= name %>
|
||||||
<% 1.upto(concurrency[process.name]) do |num| %>
|
<% 1.upto(engine.formation[name]) do |num| %>
|
||||||
# STOP CONCURRENT: <%= num %>
|
# STOP CONCURRENT: <%= num %>
|
||||||
# Stop: <%= app %>.<%= process.name %>.<%= num %>
|
# Stop: <%= app %>.<%= name %>.<%= num %>
|
||||||
kill `cat $PIDDIR/<%= process.name %>.<%= num %>.pid`
|
kill `cat $PIDDIR/<%= name %>.<%= num %>.pid`
|
||||||
rm $PIDDIR/<%= process.name %>.<%= num %>.pid
|
rm $PIDDIR/<%= name %>.<%= num %>.pid
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
rmdir $PIDDIR
|
rmdir $PIDDIR
|
||||||
|
@ -5,14 +5,27 @@ class Foreman::Export::Initscript < Foreman::Export::Base
|
|||||||
|
|
||||||
def export
|
def export
|
||||||
|
|
||||||
super
|
#super
|
||||||
|
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}")
|
||||||
|
# begin
|
||||||
|
# FileUtils.chown(user, nil, log)
|
||||||
|
# rescue Exception => e
|
||||||
|
# error("Could not chown #{log} to #{user} - #{e.message}")
|
||||||
|
# end
|
||||||
|
|
||||||
Dir["#{location}/#{app}"].each do |file|
|
name = "initscript/master.erb"
|
||||||
say "cleaning up: #{file}"
|
name_without_first = name.split("/")[1..-1].join("/")
|
||||||
clean file
|
matchers = []
|
||||||
end
|
matchers << File.join(options[:template], name_without_first) if options[:template]
|
||||||
|
matchers << File.expand_path("~/.foreman/templates/#{name}")
|
||||||
write_template "initscript/master.erb", "#{app}", binding
|
matchers << File.expand_path("../../../../data/export/#{name}", __FILE__)
|
||||||
|
path = File.read(matchers.detect { |m| File.exists?(m) })
|
||||||
|
compiled = ERB.new(path).result(binding)
|
||||||
|
write_file "#{app}", compiled
|
||||||
|
# path = export_template name
|
||||||
|
# write_template "initscript/master.erb", "#{app}", binding
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ describe Foreman::Export::Initscript, :fakefs do
|
|||||||
let(:formation) { nil }
|
let(:formation) { nil }
|
||||||
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
|
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
|
||||||
let(:options) { Hash.new }
|
let(:options) { Hash.new }
|
||||||
let(:initscript) { Foreman::Export::Initscript.new("/tmp/init", engine, options) }
|
let(:initscript) { FileUtils.mkdir_p("/tmp/init"); Foreman::Export::Initscript.new("/tmp/init", engine, options) }
|
||||||
|
|
||||||
before(:each) { load_export_templates_into_fakefs("initscript") }
|
before(:each) { load_export_templates_into_fakefs("initscript") }
|
||||||
before(:each) { stub(initscript).say }
|
before(:each) { stub(initscript).say }
|
||||||
@ -18,14 +18,6 @@ describe Foreman::Export::Initscript, :fakefs do
|
|||||||
normalize_space(File.read("/tmp/init/app")).should == normalize_space(example_export_file("initscript/app"))
|
normalize_space(File.read("/tmp/init/app")).should == normalize_space(example_export_file("initscript/app"))
|
||||||
end
|
end
|
||||||
|
|
||||||
# it "cleans up if exporting into an existing dir" do
|
|
||||||
# mock(FileUtils).rm("/tmp/init/app")
|
|
||||||
#
|
|
||||||
# initscript.export
|
|
||||||
# #require 'debug'
|
|
||||||
# initscript.export
|
|
||||||
# end
|
|
||||||
|
|
||||||
context "with concurrency" do
|
context "with concurrency" do
|
||||||
let(:options) { Hash[:concurrency => "alpha=2"] }
|
let(:options) { Hash[:concurrency => "alpha=2"] }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user