Test new interface

This commit is contained in:
Emile Cantin 2012-09-11 11:12:40 -04:00
parent 63ef82c621
commit bdf4c92b72
3 changed files with 9 additions and 17 deletions

View File

@ -39,8 +39,8 @@ USERNAME=<%= user %>
do_start()
{
mkdir -p $PIDDIR
mkdir -p <%= log_root %>
chown $USERNAME: <%= log_root %>
mkdir -p <%= log %>
chown $USERNAME: <%= log %>
# START APPLICATION: <%= app %>
<% engine.procfile.entries.each do |process| %>
# START PROCESS: <%= process.name %>
@ -48,7 +48,7 @@ do_start()
# START CONCURRENT: <%= num %>
# Start: <%= app %>.<%= process.name %>.<%= num %>
# Create $PIDDIR/<%= process.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_root %>/<%=process.name%>-<%=num%>.log 2>&1 & echo $!' > $PIDDIR/<%= process.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
<% end %>
<% end %>

View File

@ -4,24 +4,15 @@ require "foreman/export"
class Foreman::Export::Initscript < Foreman::Export::Base
def export
error("Must specify a location") unless location
FileUtils.mkdir_p location
app = self.app || File.basename(engine.directory)
user = self.user || app
log_root = self.log || "/var/log/#{app}"
template_root = Pathname.new(File.dirname(__FILE__)).join('..', '..', '..', 'data', 'export', 'initscript').expand_path
super
Dir["#{location}/#{app}"].each do |file|
say "cleaning up: #{file}"
FileUtils.rm(file)
clean file
end
master_template = export_template("initscript", "master.erb", template_root)
master_config = ERB.new(master_template).result(binding)
write_file "#{location}/#{app}", master_config
write_template "initscript/master.erb", "#{app}", binding
end
end

View File

@ -5,8 +5,9 @@ require "tmpdir"
describe Foreman::Export::Initscript, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:engine) { Foreman::Engine.new(procfile) }
let(:options) { Hash.new }
let(:formation) { nil }
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
let(:options) { Hash.new }
let(:initscript) { Foreman::Export::Initscript.new("/tmp/init", engine, options) }
before(:each) { load_export_templates_into_fakefs("initscript") }