Power down best practice

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
Baz8755
Newbie
Newbie
Posts: 9
Joined: October 7th, 2011, 2:49 am

Power down best practice

Post by Baz8755 »

The NAS box I am running SABnzbd on is set to power on and off every day, this has lead me to wonder what I should be doing to prevent any issues with SABnzbd.

I notice it has scheduling for pause and shutdown and was wondering whether to set a schedule to pause/shutdown just before the NAS box closes down. Also what would then happen when SABnzbd is restarted, will it resume any paused activity of will I have to put a schedule in for that too.

Cheers

Baz
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: Power down best practice

Post by shypike »

Forceful shutdown is always a bad idea.
If your OS cannot shutdown SABnzbd properly, then the safest is to schedule a pause.
Give it at least 5 minutes to dump its article cache to disk to be on the safe side.
You should schedule a resume event too.
The reason is that at startup the schedules are evaluated to determine what the state would have been.
Baz8755
Newbie
Newbie
Posts: 9
Joined: October 7th, 2011, 2:49 am

Re: Power down best practice

Post by Baz8755 »

So on my linkstation I suppose I could put the following line in rcS

sleep 30
/usr/bin/wget -q --delete-after "http://127.0.0.1:8080/sabnzbd/api?mode=resume"


and the following lines in the shutdown script (wherever that may be, sure I'll find it tonight)

/usr/bin/wget -q --delete-after "http://127.0.0.1:8080/sabnzbd/api?mode=pause"
sleep 300
/usr/bin/wget -q --delete-after "http://127.0.0.1:8080/sabnzbd/api?mode=shutdown"
sleep 30
User avatar
shypike
Administrator
Administrator
Posts: 19773
Joined: January 18th, 2008, 12:49 pm

Re: Power down best practice

Post by shypike »

Yes, provided that you append &apikey=blabla
And assuming you used 0.0.0.0 as host address.
If not, you'll need to use the local IP address (like 192.168.1.xxx).
Baz8755
Newbie
Newbie
Posts: 9
Joined: October 7th, 2011, 2:49 am

Re: Power down best practice

Post by Baz8755 »

Sorted, pretty much as discussed.

Didn't need to send a resume on startup in rcS as it seems to start in a running state.
Placed shutdown commands in rcDown, this gave me a little trouble as linkstation seems to like replacing on every boot and I couldn't work out where. So I just recopied it back at the end of rcS.
Baz8755
Newbie
Newbie
Posts: 9
Joined: October 7th, 2011, 2:49 am

Re: Power down best practice

Post by Baz8755 »

In case anyone else is interested here is my startup/shutdown script for Buffalo Linkstation.

You will need to reference it in rcS, rcDown,standyby,rcDown and will then need to take a copy of rcDown as SABnzbd.rcDown as this seems to get overwritten.

Upon shutdown the script will set SABnzbd into pause mode, wait up to 10 minutes for any unpacks to finish and then wait up to 10 minutes for SABnzbd to cleanly close down.

Enjoy.

#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin
#
#Script to start/stop SABnzbd
#

Send_wait_pause()
{
#Send pause command
/usr/bin/wget -q -O - "http://192.168.0.21:8080/sabnzbd/api?mo ... ikey=<your key>"
LoopCount=0
ClearCount=0
#Wait for RARs & PARs to close
while [ $LoopCount -lt $2 -a $ClearCount -lt $1 ]
do
ProcessCount=$(ps | grep -v grep | grep -e unrar -e par2 -e unzip | wc -l)
if [ $ProcessCount -eq 0 ]
then
ClearCount=`expr $ClearCount + 1`
else
ClearCount=0
fi
LoopCount=`expr $LoopCount + 1`
sleep 30
done
}

Send_wait_close()
{
#Send close command
/usr/bin/wget -q -O - "http://192.168.0.21:8080/sabnzbd/api?mo ... ikey=<your key>""
LoopCount=0
ClearCount=0
#Wait for RARs & PARs & SABnzbd to close
while [ $LoopCount -lt $2 -a $ClearCount -lt $1 ]
do
ProcessCount=$(ps | grep -v grep | grep -e unrar -e par2 -e unzip -e SABnzbd.py | wc -l)
if [ $ProcessCount -eq 0 ]
then
ClearCount=`expr $ClearCount + 1`
else
ClearCount=0
fi
LoopCount=`expr $LoopCount + 1`
sleep 30
done
}

Startup()
{
python2.5 /opt/share/SABnzbd/SABnzbd.py -f /opt/share/SABnzbd/SABnzbd.ini -d -s 0.0.0.0
cp /etc/init.d/SABnzbd.rcDown /etc/init.d/rcDown
}


case $1 in
start)
Startup
;;
resume)
Startup
;;
standby)
Send_wait_pause 4 20
Send_wait_close 1 20
;;
stop)
Send_wait_pause 4 20
Send_wait_close 1 20
;;
*)
;;
esac
Post Reply