Recovering from a TT downtime
This isn't so much an issue and as a question. What do you do in your bots so they automatically recover from a TT downtime?
For my website, I created a cronjob that kill my process and start a new one every hour. Pretty bad, I know !
I do pretty much the same thing as Alain, I have a set interval in which my "main bot" logs in to check for available rooms. If it isn't able to successfully complete this task, it errors out and tries again in a couple minutes. I don't know if there is really any other suitable way to do this.
Usually the error I get is "Connection Refused" as TT's server is usually up, just only accepting certain people to connect. There was one time I got a TIMEOUT error and that's when Amazon's servers were just flat out offline I believe.
Oh... I like @Izzmo's idea. I'll have to add that to my bot.
I'll keep this open until I can get something running. Then post an example of how to bring the bot back up after a downt time? Anyone know of a way to simulate a downtime?
Terminate the socket connection manually. You can do this with a packet inspector or something like Process Explorer. (I don't think Process Hacker supports it though).
Okay. I like that idea. I am on OS X. I'll figure it out from there.
When I start a bot, I store the PID along with the information on when it started/stopped. I also have a cron job that runs every min to make sure if the bot says its active that the PID still exists. If it does not, I flag it as inactive and start a new instance. Doesnt work sometimes, but has saved me much heartburn.
This template seems to be working. I am using it in conjuction with forever. It has automatically recovered from some sort of problems a couple times now.
Hey Alain, any chance you could share that cronjob?
The cronjob:
0 */1 * * * /var/crawler/watchdog.sh
watchdog.sh:
#!/bin/bash
killall python
nohup python /var/crawler/main.py &
The script was in python, but you could replace every occurence of python by node (I think !)