Turntable-API icon indicating copy to clipboard operation
Turntable-API copied to clipboard

Recovering from a TT downtime

Open MikeWills opened this issue 14 years ago • 10 comments

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?

MikeWills avatar Aug 15 '12 13:08 MikeWills

For my website, I created a cronjob that kill my process and start a new one every hour. Pretty bad, I know !

alaingilbert avatar Aug 15 '12 14:08 alaingilbert

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.

Izzmo avatar Aug 15 '12 14:08 Izzmo

Oh... I like @Izzmo's idea. I'll have to add that to my bot.

MikeWills avatar Aug 15 '12 14:08 MikeWills

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?

MikeWills avatar Sep 06 '12 18:09 MikeWills

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).

Izzmo avatar Sep 06 '12 20:09 Izzmo

Okay. I like that idea. I am on OS X. I'll figure it out from there.

MikeWills avatar Sep 06 '12 20:09 MikeWills

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.

paulnus avatar Sep 20 '12 00:09 paulnus

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.

MikeWills avatar Sep 27 '12 13:09 MikeWills

Hey Alain, any chance you could share that cronjob?

ehedaya avatar Dec 25 '12 04:12 ehedaya

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 !)

alaingilbert avatar Dec 25 '12 06:12 alaingilbert