View Single Post
  #102  
Old 12-19-2015, 10:43 AM
doobydoo doobydoo is offline
Junior Member
 
Join Date: Dec 2015
Posts: 2
doobydoo is on a distinguished road
Default

Re: Automated Chaturbate Recording Under Linux


So I pieced together a solution, or a hacked up work around to deal with script disconnects when a server error occurs.

Basically, it’s just a script to restart capturebate when a certain string shows up in the output log.

I’m no scripting guru, so this is a novice attempt. I pieced the script together from examples I found around the web. Hopefully a scripting expert can improve on it.

I’m running capturebate on Ubuntu MATE. If you’re running a different distro, you may need to install any dependencies the script calls on in order to get it to work.

Here’s how it should work. If Errno or BadStatusLine show up in the output log, the script will kill any capturebate running scripts, then popup a notification window listing the error causing it to restart, then wait two minutes, and finally restart capturebate and continue monitoring the output log.

Copy the below listed code into a text file, name it monitor.sh, and save it into the root of your capturbate directory. After the file is created, right click it and click the permissions tab, then tick Allow executing file as a program.

Code:
#!/bin/bash

sudo tail -fn0 output.log |
  grep --line-buffered 'BadStatusLine\|Errno' |
    while read line; do
      timestamp=${line/}
      msg=${line#*]: }
      notify-send -u critical "SCRIPT RESTARTED initiated by" "$timestamp" -t 0 & 
pkill -f rtmpdump 
pkill -f main.py &
sleep 2m
python main.py &
    done
Now, start capturebate as normal, then run this script by opening a command prompt from within the capturbate directory, and use the command sudo ./monitor.sh

After that, the script should run and monitor the output log for the errors listed in the script, and restart when necessary.

I'm not sure how stable this script works, so monitor its operation and post any problems or improvements.
Reply With Quote