def soft_shutdown
@soft_termination_linger_thread ||= Thread.new do
debug("Soft termination initiated")
if @detach_key && @pool_account_username && @pool_account_password
client = MessageClient.new(@pool_account_username, @pool_account_password)
begin
client.pool_detach_process_by_key(@detach_key)
ensure
client.close
end
end
wait_until_all_threads_are_idle
debug("Soft terminating in #{@soft_termination_linger_time} seconds")
sleep @soft_termination_linger_time
@graceful_termination_pipe[1].close rescue nil
end
end