DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2009-06-02 19:24:42

bfg100k
Member
Registered: 2007-09-15
Posts: 55

[REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

slimserver_standby_daemon is a lightweight program that works together with the SqueezeBox Plugin Server Power Control to automatically stop/start SqueezeCenter and optionally MySQL based on the status of SqueezeBox clients. i.e. when there are no active clients, the slimserver and mysql services will be stopped to conserve resources on the DNS-323. Then when an active client tries to connect, the daemon will automatically restart the slimserver and mysql services.

Features
* Automatically stop slimserver and optionally MySQL when there are no active SqueezeBox clients
* Automatically start slimserver and MySQL when an active SqueezeBox client tries to connect
* Includes a startup script so that the lightweight daemon is started on boot/reboot instead of the resource hungry slimserver + mysql combo

Pre-requisite
* Server Power Control

Acknowledgement
This program is based on the work developed by Yannick.
What I've done is to make it more robust, configurable and fit the ffp environment better.

In addition, I created a startup script for the standby daemon so that ffp will start the standby daemon rather than SqueezeCenter on boot/reboot. The assumption here is that you most likely do not need SqueezeCenter when you boot/reboot the box and you would rather let a SqueezeBox client trigger the startup of SqueezeCenter than to have it unnecessarily load up my boot process and increase the boot time.

Installation
   1. Set up standby daemon script
         1. Download and install script

Code:

                # cd /ffp
                # wget -O standby_daemon.tar.gz http://dns323.kood.org/forum/attachment.php?item=497
                # tar -xzvf standby_daemon.tar.gz
                # rm standby_daemon.tar.gz

2. Configure sudoers to allow user nobody to trigger the script without password. [IMPT: do not blindly copy the code below! replace {your_hostname} with your real hostname!]

Code:

                # cd /ffp/etc
                # chmod u+w sudoers
                # echo "nobody {your_hostname}= NOPASSWD: /ffp/sbin/slimserver_standby_daemon.pl" >> sudoers
                # chmod u-w sudoers

2. Set up SqueezeCenter plugin - Server Power Control
         1. Download and install plugin from here

Code:

                # cd /ffp/lib/squeezecenter/Plugins/
                # wget -O SrvrPowerCtrl.zip http://forums.slimdevices.com/attachment.php?attachmentid=7357&d=1241562529
                # unzip SrvrPowerCtrl.zip
                # rm SrvrPowerCtrl.zip

2. Restart SqueezeCenter to load the newly installed plugin.
         3. Go to the settings page of the plugin (Settings>Plugins, look for Server Power Control and click on settings on the right) after SqueezeCenter has restarted
         4. Check the first two options (Shutdown and Shutdown to SqueezeNetwork) and enter "sudo /ffp/sbin/slimserver_standby_daemon.pl" in the textbox below it (both of them). Leave the rest of the options unchecked as we can't use them on the DNS-323.
         5. At the end of the settings dialog, select the option Monitor idle Players and select Shutdown server for the field Action to take after idle time. Optionally you can also setup the same in End of day action with a shorter idle time.
         6. Save the settings and you are done.

   3. [Optional] Start standby daemon instead of SqueezeCenter on boot/reboot

Code:

          # cd /ffp/start
          # chmod a-x slimserver.sh
          # chmod a+x slimserver_standby_daemon.sh

4. Tips and Tricks
         1. The standby daemon outputs a log file called standby_daemon.log in SqueezeCenter's log directory (i.e. /ffp/lib/squeezecenter/Logs/). It records the timestamps of the shutdown and startup events which I find useful for tracking the uptimes as well as for debugging purposes.
         2. The default settings in the standby daemon script does not shutdown MySQL. (My instance of MySQL is used for other purposes hence I have to let it run independently). If you wish to have the script manage that, change the var $stop_mysql from 0 to 1. It will however, start MySQL if its not already running. (Make sense right?!)


A couple of things still need to be sorted out in this setup:

1. Wakeup prior to alarm - Since SqueezeCenter is no longer running all the time, alarms that plays from SqueezeCenter will not work. Initial idea is to modify script to set up a cron job to wake SqueezeCenter a few minutes prior to the alarm being triggered. Note that this should not affect you if your alarms are set on SqueezeNetwork and you have configured Server Power Control to automatically switch you to SqueezeNetwork when SqueezeCenter is being shutdown.

2. Scheduled music library scans - Since SqueezeCenter is no longer running all the time, the scheduled daily scans may not be taking place anymore. Initial idea is to modify script to look for this setting and setup a cron job for it when the daemon is active.

I do not have any urgency to get these features working as I currently do not use them. I will probably get round to them if there is demand for it.

Last edited by bfg100k (2009-06-02 19:25:29)


Attachments:
Attachment Icon slimserver_standby_daemon.tar.gz, Size: 2,575 bytes, Downloads: 760

Offline

 

#2 2009-09-18 14:23:36

mrbillions
Member
Registered: 2009-09-02
Posts: 16

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

That's a great idea and I followed all the steps with the install without major dramas but I can't seem to do step 2:

# cd /ffp/etc
                # chmod u+w sudoers
                # echo "nobody {your_hostname}= NOPASSWD: /ffp/sbin/slimserver_standby_daemon.pl" >> sudoers
                # chmod u-w sudoers

I don't have a sudoers file. Please explain.
I presume without this file/step it all will not work?

Also how to stop mysql at the same time as slimserver? You mention that this is an option but I can't see anywhere to turn this option on.

Thanks a billion...

Offline

 

#3 2009-09-18 16:14:21

mrbillions
Member
Registered: 2009-09-02
Posts: 16

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

Figured the mysql stop/start option out which appears to live in /ffp/sbin/slimserver_standby_daemon.pl but the missing sudoers question still remains...i don't have a such a file. Where is it and how does it get there? Thanks

Offline

 

#4 2009-09-24 19:13:02

bfg100k
Member
Registered: 2007-09-15
Posts: 55

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

mrbillions wrote:

Figured the mysql stop/start option out which appears to live in /ffp/sbin/slimserver_standby_daemon.pl but the missing sudoers question still remains...i don't have a such a file. Where is it and how does it get there? Thanks

It doesn't matter if its not already there. Just create a blank file with that name and add in the required line will do.

Offline

 

#5 2009-11-18 17:19:55

molli2000
New member
Registered: 2009-11-09
Posts: 3

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

Hi there,
today, I ´ve read  the  first time  about the standby-daemon. Great idea  !!!
Can I  now make the the harddisk hibernation    possible , while running  the squeezebox server on DNS-323?
Because now, my harddisk  only hibernates, when the  server_plug  ist not  installed.....

Offline

 

#6 2009-11-22 13:10:22

djcult
Member
Registered: 2008-07-07
Posts: 12

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

bfg100k,

Thanks for your work on this. I followed your instructions and it all works to a point:

When the server shuts down (either due to idle timeout or when I use the "shutdown in 15 seconds" option from the remote), your script is called correctly - it terminates slimserver, and starts listening to incoming connections on port 3484.

The problem is that my client player seems to be continuously looking for the server because no sooner has it started listening, it finds traffic from the player and starts up - leading to a bit of a loop.

I have quite an old client (this one: http://wiki.slimdevices.com/index.php/Squeezebox). What client do you have? Maybe that's the difference?

Cheers

Offline

 

#7 2009-11-24 08:32:19

molli2000
New member
Registered: 2009-11-09
Posts: 3

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

@ djkult,

sorry for a little question beetween:
Did your  harddisk hibernate, after the sqzeezebox-server was  shutdown ??

Offline

 

#8 2009-11-24 08:42:41

djcult
Member
Registered: 2008-07-07
Posts: 12

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

molli2000:

It doesn't have time, the server starts up again straight away.

Offline

 

#9 2009-11-24 19:00:21

molli2000
New member
Registered: 2009-11-09
Posts: 3

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

I think, I  still don´t understand   the start/stop daemon tool....

Why should  I shutdown the squeeze-server, when the harddisk are still running after this......

bfg100k  wrote , it will "conserve resources" on the 323. What resources does he mean ????

Offline

 

#10 2009-11-28 22:31:03

djcult
Member
Registered: 2008-07-07
Posts: 12

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

molli2000,

Slimserver will prevent your disks from spinning down while it's running. So if the daemon stops slimserver when it's not in use, your disks will at least have the _chance_ to spin down.

Maybe in your case there's something in addition to slimserver which is keeping them running.

Offline

 

#11 2011-01-04 17:04:11

rintje
Member
Registered: 2010-02-08
Posts: 14

Re: [REL]slimserver_standby_daemon-auto start/stop SqueezeCenter on demand

Does anyone use this plugin with Squeezebox server 7.6 ?


Conceptronic CH3SNAS | Firmware v1.05b1 | Funplug 0.5 on USB
Mods: Cleanboot, Chkbutton2, NZBGet, Squeezebox Server

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB