From bcac99b8cdcd0f32c4720d822d3049e3426f6cd3 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 30 Oct 2013 20:24:58 +0000 Subject: implement before_exec hook This allows modifying the command-line (as an array) passed to Kernel#exec, as well as running anything necessary. --- lib/yahns/server.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/yahns/server.rb') diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb index 6439918..220381b 100644 --- a/lib/yahns/server.rb +++ b/lib/yahns/server.rb @@ -11,6 +11,7 @@ class Yahns::Server # :nodoc: attr_accessor :daemon_pipe attr_accessor :logger attr_writer :user + attr_writer :before_exec attr_writer :worker_processes attr_writer :shutdown_timeout attr_writer :worker_atfork_prepare @@ -30,6 +31,7 @@ class Yahns::Server # :nodoc: @listeners = [] @pid = nil @worker_processes = nil + @before_exec = nil @worker_atfork_prepare = @worker_atfork_parent = @worker_atfork_child = nil @user = nil @queues = [] @@ -246,6 +248,7 @@ class Yahns::Server # :nodoc: Dir.chdir(@config.value(:working_directory) || Yahns::START[:cwd]) cmd = [ Yahns::START[0] ].concat(Yahns::START[:argv]) @logger.info "executing #{cmd.inspect} (in #{Dir.pwd})" + @before_exec.call(cmd) if @before_exec cmd << redirects exec(*cmd) end -- cgit v1.2.3-24-ge0c7