#!/bin/sh
if ps -p `cat /opt/cpguard/app/crons/.pid` > /dev/null
then
    echo "Restarting cpguard-agent"    
else
    echo "Starting cpguard-agent"
fi

#cleanup

pkill -f cpguard\-agent

> /opt/cpguard/logs/worker_output
rm -f  /dev/shm/Sync_Event*CpgTask*

#start worker
/opt/cpguard/app/crons/worker.php >> /opt/cpguard/logs/worker_output 2>&1 &

sleep 1

if ps -p `cat /opt/cpguard/app/crons/.pid` > /dev/null
then
    echo "Start success PID : " `cat /opt/cpguard/app/crons/.pid`
else
    echo "Start failed!"
fi


