ok i have done this from ruby_block
# for managing service
# jboss block until operational
ruby_block "block_until_operational" do
block do
until IO.popen("netstat -lnt").entries.select { |entry|
entry.split[3] =~ /:#{node[:jboss][:default_port]}$/
}.size == 1
Chef::Log.debug "service[jboss] not listening on port #{node[:jboss][:default_port]}"
sleep 1
end
end
action :nothing
end
i created this ruby block that would listen to port 8080 until it returns 1 (started) and called this via
service "jboss" do
action :start
notifies :create, 'ruby_block[block_until_operational]', :immediate
end