first attempt at screen-based running

This commit is contained in:
David Dollar
2010-06-09 12:13:02 -04:00
parent 3f48d7c541
commit 56f8603a5d
2 changed files with 21 additions and 0 deletions
+7
View File
@@ -20,6 +20,13 @@ class Foreman::CLI < Thor
Foreman::Engine.new(procfile).execute(process)
end
desc "screen [PROCFILE]", "Run the app described in PROCFILE as screen windows"
def screen(procfile="Procfile")
error "#{procfile} does not exist." unless procfile_exists?(procfile)
Foreman::Engine.new(procfile).screen
end
desc "export APP [PROCFILE] [FORMAT]", "Export the app described in PROCFILE as APP to another FORMAT"
def export(app, procfile="Procfile", format="upstart")
+14
View File
@@ -1,5 +1,6 @@
require "foreman"
require "foreman/process"
require "tempfile"
class Foreman::Engine
@@ -34,6 +35,19 @@ class Foreman::Engine
run_loop
end
def screen
tempfile = Tempfile.new("foreman")
tempfile.puts "sessionname foreman"
processes.each do |name, process|
tempfile.puts "screen -t #{name} #{process.command}"
end
tempfile.close
system "screen -c #{tempfile.path}"
tempfile.delete
end
def execute(name)
run(processes[name], false)
end