A known problem of running SBS on a DNS-323 is that the disk never hibernate. Some time ago I had presented in this post (http://forums.slimdevices.com/showpost.php?p=386614&postcount=110) a simple solution to make the server start/stop automatically when a client connects to it. This solution involving the SvrPowerControlPlugin (see http://forums.slimdevices.com/showthread.php?t=48521) and a simple script listening for a connection on the port used by SBS basically worked and the script was largely improved by Sydney on his blog (http://bfg100k.blogspot.com/2009/05/on-demand-startstop-squeezecenter.html) but it also had a drawback: when you try to connect a squeezebox to a "sleeping" server using this technique, you have to wait about 2min for the server to be up before you can hear music. This is a trade-off to save energy and the lifetime of your hard-disk, but it is not really comfortable. After having posted my technique I was busy on other things and hadn't looked again at this until shortly when I tried different approaches to get the disk sleep without this drawback.
The first thing I tried was to move the ffp plugins to an USB stick. There are several ready to use scripts on the internet to do that easily. I used this one (http://forum.dsmg600.info/t3203-setup.sh-script-%28and-documenntation%29-mount-root.html) as well as the additional explanations there: (http://bfg100k.blogspot.com/2008/11/upgrading-ffp-05-and-moving-it-to-usb.html). Moving ffp to an USB stick doesn't solve the hibernation problem with Squeezebox Server, because the swap file is still on the disk. But it makes ffp self contained on the stick (you can remove the stick to boot without it), and allows the disk to stay down until you really need it. The next thing I tried was to move the swap file to the USB stick. There are good instructions there (http://forum.dsmg600.info/viewtopic.php?id=3400) explaining how to do it. The result was disappointing: it removed the disk accesses that prevented the hibernation, but the read rate of the USB stick was so slow that everything ran at a felt pace of 10% the original speed of the system. Maybe the problem is that I used the cheapest 2Gb stick I could find, but I didn't want to invest more, since it is quite probable that the stick wouldn't last very long with the constant write operations caused by the swap. So I gave up that idea. I kept ffp on the USB stick but with a swap on the disk. I finally looked a bit deeper in my original idea of waiting for client activity to start the full server and ran some tests to find a way to reduce this 2min waiting time before the server is up. My idea was that instead of running a small program starting the full SBS when clients connect, I could start at least a part of SBS up to a point that doesn't cause swap activities. During these tests, I found out that the real problem that made the disk wake up are the constant communication between SBS and MySQL (apparently 1 query every 30s). That's how I came to the following solution: - Instead a starting a dummy program listening on the port 3483 and starting SBS when a connection is detected, I start SBS until a point where it is at 95% initialized, but the network activity hasn't started yet. Then I freeze the execution at that point until a connection is detected on port 3483 (like with the old technique). SBS in this frozen status doesn't prevent the disk to swap. A part of goes to the swap, because it is too big to fit in memory, but since it sleeps, it is never read back from the swap before a connection is detected. Once a connection is detected, the initialiation of SBS is resumed and at the end the server is exactly in the same state as if it had been started normally. The difference between this approach and the old technique is that instead of having to wait 2min for the who server to come up, you only need to wait a couple of seconds for the last 5% of the initialization to start the network activity. Later, when all clients are idle, the SvrPowerControl plugin is used to connect all clients to MySqueezeBox.com and restart the server which comes back in this sleeping state initialized at 95% until a client connects again. The drawback of this technique is that it requires a small change in the code of SBS, but the change is so minimal that it can be done by anybody. Here is the procedure to follow: 1)##### Prerequesites My starting point is FFP 0.5 and SBS 7.4.1 installed from the fonz packages (http://www.inreto.de/dns323/fun-plug/0.5/) on an USB stick. I use the option of the USB script rebooting off the USB stick, since it is supposed to save more RAM (see explanation under http://forum.dsmg600.info/t3203-setup.sh-script-%28and-documenntation%29-mount-root.html). The firmware of my DNS323 is 1.05. I am pretty sure that the same technique would work even if ffp is not installed on an USB stick, but I didn't test. 2)##### Install the SrvrPowerControl plugin - Telnet your DNS323 Code: -------------------- # cd /ffp/lib/squeezecenter/Plugins/ # wget -O SrvrPowerCtrl.zip http://srvrpowerctrl.googlecode.com/svn/SrvrPowerCtrl_beta.zip # unzip SrvrPowerCtrl.zip # rm SrvrPowerCtrl.zip -------------------- 3)##### Modify Slimserver.pl - Edit the file /ffp/lib/squeezeboxserver/slimserver.pl as follow (alternative you can replace it by the new version I attached to this thread, if you are using exactly the same version of SBS as I do: 7.4.1) - Add the line in bold at the beginning of the file: Code: -------------------- (...) require 5.008_001; use strict; use warnings; USE SOCKET; (...) -------------------- - Search for the following section in the code (line 456) and comment out the 2 lines in bold Code: -------------------- (...) main::INFOLOG && $log->info("UDP init..."); Slim::Networking::UDP::init(); # MAIN::INFOLOG && $LOG->INFO(\"SLIMPROTO INIT...\"); # SLIM::NETWORKING::SLIMPROTO::INIT(); main::INFOLOG && $log->info("Cache init..."); Slim::Utils::Cache->init(); (...) -------------------- - Search for the following section (at line 556) and add the code in bold Code: -------------------- (...) Slim::Utils::Timers::setTimer( undef, time() + 30, \&Slim::Utils::Update::checkVersion, ); ####### CHANGED FOR DNS323 ####### SUSPEND THE EXECUTION UNTIL A CLIENT TRIES TO CONNECT MY $SS_PORT = 3483; MY $PORT = SHIFT || $SS_PORT; MY $PROTO = GETPROTOBYNAME('TCP'); # CREATE A SOCKET SOCKET(SERVER, PF_INET, SOCK_STREAM, $PROTO) OR DIE \"SOCKET: $!\"; SETSOCKOPT(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) OR DIE \"SETSOCK: $!\"; MY $PADDR = SOCKADDR_IN($PORT, INADDR_ANY); # BIND AND LISTEN BIND(SERVER, $PADDR) OR DIE \"BIND: $!\"; LISTEN(SERVER, 1) OR DIE \"LISTEN: $!\"; # WAIT FOR A CONNECTION MY $CLIENT_ADDR = ACCEPT(CLIENT, SERVER); # TERMINATE CONNECTION WITH CLIENT CLOSE CLIENT; CLOSE SERVER; # NOW START THE UDP LISTENING OF THE SQUEEZEBOX SERVER # (WHAT WAS COMMENTED OUT BEFORE) MAIN::INFOLOG && $LOG->INFO(\"SLIMPROTO INIT...\"); SLIM::NETWORKING::SLIMPROTO::INIT(); ####### END OF CHANGE main::INFOLOG && $log->info("Squeezebox Server HTTP enable..."); Slim::Web::HTTP::init2(); # otherwise, get ready to loop $lastlooptime = Time::HiRes::time(); (...) -------------------- 4)##### Modify /ffp/start/slimserver.sh This script needs to be slightly modified because in the current version the restart command fails, because it doesn't wait long enough for the server to be stopped before starting it again. Edit the file and add the line in bold in the following section: Code: -------------------- slimserver_stop() { if [ -r /ffp/lib/squeezeboxserver/Logs/slimserver.pid ]; then kill $(cat /ffp/lib/squeezeboxserver/Logs/slimserver.pid) fi killall slimserver.pl 2>/dev/null *sleep 30* } -------------------- 5)##### Configure sudoers to allow the user nobody to restart SBS Code: -------------------- # cd /ffp/etc # chmod u+w sudoers # echo "nobody ALL= NOPASSWD: /ffp/bin/sh /ffp/start/slimserver.sh restart" >> sudoers # chmod u-w sudoers -------------------- 6)##### Start the server Code: -------------------- # sh /ffp/start/slimserver.sh start -------------------- With the command top, you can observe that it starts normally and at some point, with a memory usage of about 92% it sleeps. Now let a client connect to it, and you'll see with top that it wakes up and the client gets the connection shortly after that. 7)##### Edit the properties of the SvrPowerControl: Open the web interface, edit the properties of the SvrPowerControl plugin as follow: - Check the option "Include Shutdown to SqueezeNetwork as a menu option?" - Edit the command "Shutdown Command (include full path and cmd line args):" as follow: Code: -------------------- sudo /ffp/bin/sh /ffp/start/slimserver.sh restart -------------------- - Let all the other options unchecked - In the section "Idle Player Monitor", check the option "Monitor idle Player" and set the "Action to take after idle time:" to "Shutdown to SqueezeNetwork" - Setup the idle time you allow before the server goes to bed. - Save the properties After all clients are idle for the time you set in the properties, you should see the process of the server stop and restart to the standby menu. Note that if the clients are not completely powered off and still connected to the server, it will cause the server to fully start again. That's why it is recommanded to setup the properties of the SvrPowerControl to "Shutdown to SqueezeNetwork", and that you only connect to the DNS323 when you want to listen to your local library. For alarms and internet radio you can use SqueezeNetwork... Yannick +-------------------------------------------------------------------+ |Filename: slimserver.pl.zip | |Download: http://forums.slimdevices.com/attachment.php?attachmentid=8605| +-------------------------------------------------------------------+ -- yannick ------------------------------------------------------------------------ yannick's Profile: http://forums.slimdevices.com/member.php?userid=19770 View this thread: http://forums.slimdevices.com/showthread.php?t=70856
_______________________________________________ plugins mailing list [email protected] http://lists.slimdevices.com/mailman/listinfo/plugins
