Merge pull request #340 from ldmosquera/set_env_var_with_process_name
Set FOREMAN_PROCESS_NAME env var for spawned procs
This commit is contained in:
@@ -302,6 +302,10 @@ private
|
|||||||
|
|
||||||
def name_for(pid)
|
def name_for(pid)
|
||||||
process, index = @running[pid]
|
process, index = @running[pid]
|
||||||
|
name_for_index(process, index)
|
||||||
|
end
|
||||||
|
|
||||||
|
def name_for_index(process, index)
|
||||||
[ @names[process], index.to_s ].compact.join(".")
|
[ @names[process], index.to_s ].compact.join(".")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -350,7 +354,8 @@ private
|
|||||||
reader, writer = create_pipe
|
reader, writer = create_pipe
|
||||||
begin
|
begin
|
||||||
pid = process.run(:output => writer, :env => {
|
pid = process.run(:output => writer, :env => {
|
||||||
"PORT" => port_for(process, n).to_s
|
"PORT" => port_for(process, n).to_s,
|
||||||
|
"PS" => name_for_index(process, n)
|
||||||
})
|
})
|
||||||
writer.puts "started with pid #{pid}"
|
writer.puts "started with pid #{pid}"
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ describe "Foreman::CLI", :fakefs do
|
|||||||
output.should =~ /test.1 \| testing/
|
output.should =~ /test.1 \| testing/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "sets PS variable with the process name" do
|
||||||
|
without_fakefs do
|
||||||
|
output = foreman("start -f #{resource_path("Procfile")}")
|
||||||
|
output.should =~ /ps.1 \| PS env var is ps.1/
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ echo: bin/echo echoing
|
|||||||
env: bin/env FOO
|
env: bin/env FOO
|
||||||
test: bin/test
|
test: bin/test
|
||||||
utf8: bin/utf8
|
utf8: bin/utf8
|
||||||
|
ps: bin/echo PS env var is $PS
|
||||||
|
|||||||
Reference in New Issue
Block a user