Class: Foreman::CLI
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
- #export(format, location = nil) ⇒ Object
- #run(*args) ⇒ Object
- #start(process = nil) ⇒ Object
- #version ⇒ Object
Methods included from Helpers
Class Method Details
.is_thor_reserved_word?(word, type) ⇒ Boolean
Hackery. Take the run method away from Thor so that we can redefine it.
31 32 33 34 |
# File 'lib/foreman/cli.rb', line 31 def is_thor_reserved_word?(word, type) return false if word == "run" super end |
Instance Method Details
#check ⇒ Object
69 70 71 72 73 74 |
# File 'lib/foreman/cli.rb', line 69 def check check_procfile! engine.load_procfile(procfile) error "no processes defined" unless engine.processes.length > 0 puts "valid procfile detected (#{engine.process_names.join(', ')})" end |
#export(format, location = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/foreman/cli.rb', line 57 def export(format, location=nil) check_procfile! load_environment! engine.load_procfile(procfile) formatter = Foreman::Export.formatter(format) formatter.new(location, engine, ).export rescue Foreman::Export::Exception => ex error ex. end |
#run(*args) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/foreman/cli.rb', line 81 def run(*args) load_environment! if File.file?(procfile) engine.load_procfile(procfile) end pid = fork do begin engine.env.each { |k,v| ENV[k] = v } if args.size == 1 && process = engine.process(args.first) process.exec(:env => engine.env) else exec args.shelljoin end rescue Errno::EACCES error "not executable: #{args.first}" rescue Errno::ENOENT error "command not found: #{args.first}" end end trap("INT") do Process.kill(:INT, pid) end Process.wait(pid) exit $?.exitstatus || 0 rescue Interrupt end |
#start(process = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/foreman/cli.rb', line 37 def start(process=nil) check_procfile! load_environment! engine.load_procfile(procfile) engine.[:formation] = "#{process}=1" if process engine.start end |