I'm in the process of finishing a Jabber/gTalk bot, but while talking to a friend of mine he asked "what happens if the bot dies?"
It's a good thing he asked because I hadn't thought of that. So here's what I did to remedy a future problem.
I created a cron that runs a shell script every five minutes, so if the bot process does happen to die it won't be down for longer than five minutes. The script itself is fairly simple. It does nothing more than check to see if the process is running, if not start it.
#!/bin/bash
ps -ef | grep -v grep | grep gasbuddy.php
if [ $? -eq 1]
then
`/path/to/gasbuddy`
else
echo "eq 0 - gasbuddy found - do nothing"
fi
Almost too simple. I guess you could further this with logs, but I have no need for logs right now.
Replies: 0
Leave a Reply