Try this:
the recipe:
execute "startHAPROXY" do
command "./start.sh"
cwd "/home/#{node["haproxyUser"]}/haproxy"
action :nothing
end
start.sh:
#!/bin/bash -e
kill -9 `ps -ef | grep haproxy | grep -v grep | awk '{print $2}'`
cd /home/lb/haproxy
/home/lb/haproxy/haproxy -f /home/lb/haproxy/haproxy.cfg
- You should better use
cwd
attribute ofexecute
resource to change working directory. - Changed script to "bash" and added "-e" for it to fail on the first error it encounters.
- You don't need
exit $?
at the end as exit status of the script will automatically be the exit status of last command in it.