PDA

View Full Version : HowTo: Prevent server from suspend/hibernate while Squeezecenter playing?



Ausir
2009-09-23, 23:57
I have a SB3 Classic connected wireless to a router, and Squeezecenter running on a wired ubuntu.9.04-computer. The computer/fileserver is set to go into suspend after X minutes of idling. And it also works to "wol" it. My problem is that it suspends while playing on the SB3. Sending output from Squeezecenter doesn't seem to prevent suspension. The server is also used for streaming movies and tv-series to an HTPC, so I don't think SrvrPowerMng-plugin is the answer for me. Anyone have a solution or idea of how I'm supposed to solve this problem?

pablolie
2009-09-24, 08:33
in Ubuntu's System Menu, go to Preferences and Power Savings, move the slide ruler for Sleep all the way to the right for "Never"...

Ausir
2009-09-24, 10:07
Well, that slider is how I set it to suspend, so I want to keep it that way. What I would like is to have ubuntu recognize that Squeezecenter (and perhaps other programs like rtorrent or samba-share) is running/sending packages and prevent the suspension/hibernate.

philly4
2009-09-25, 14:39
I have been trying to figure out how to get this to work for a while and have never found a good answer. Using the serverpowerctrl plugin is the best solution I have been able to find, but it does not make the system work as desired. I haven't found a sleep solution for ubuntu that will monitor the system use (keyboard and mouse etc.) and squeezecenter use. If anyone has one, I'd love to know about it.

pablolie
2009-09-25, 22:59
There are issues, and the Ubuntu forums are full of threads , search for
sudo ethtool -s eth0 wol g
...and perhaps that is all you need. Note you'll seemingly have to do it every time you restart, there are known issues with 9.04 network manager...

In my newest creation it works but the result isn't pretty. You have to not once, but twice tell the player to reconnect to squeezecenter.

In fact it is home servers' rather inconsistent sleep behavior, both in Ubuntu and Vista, that lead me to no configure a dedicated Squeeezecenter server, which at worst consumes 26W peak and thus can be kept on... a decision that was not quite as defensible with a 170W server...

Ausir
2009-09-26, 11:04
Read the title again, HowTo Prevent server from suspend...

I don't have any problem at all to wake my server up after following this instruction: http://ubuntuforums.org/showthread.php?t=234588

My problem, which I perhaps didn't manage to write down properly, is that my server suspends after a while (whatever time I've set it to suspend idling) as I'm playing my SB3. I don't want to manually go to the computer running Squeezecenter every 45 minutes to prevent it from suspending. This is not a Squeezecenter issue really, but an ubuntu-issue. I just thought that I wasn't the only SB-user who had come upon this and thus looked for help here. (I've asked for help on a ubuntu-forum as well, but no luck yet.)

epoch1970
2009-09-26, 12:34
Hi.
I think you should get interested in SrvPowerControl again. My suggestion is the following:
- remove power management from the machine (disable the desktop/gnome daemon, but try to keep acpid). Now the server will never sleep.
- install srvPowrControl. Now the server will be forced to sleep when the SBs are not playing.
- add an ad-hoc script that watches the activity of the other services you're interested in. I suppose watching opened files and network activity would be what you want. When your script sees activity, it could block srvPowerControl from trying to shutdown the machine. When there is no more activity, release the block.
This should work ok.

If the system is also a Desktop, then removing all PM may not a great idea, esp. if you loose the screensaver (and still use a CRT). So you'd need to fix the issue in a bit more subtle way.
This aside, you can use the same trick of blocking SC until the user is logged in. srvPowerControl does this on MacOS and it works great. Until you're logged-in, even if there is nobody watching a movie or playing music, and for 20 minutes you can't decide how to start that letter... the machine will not shutdown on you.
AFAIK there is no X11 equivalent, but GDM (the Gnome login window) has provision for setting a srvPowercontrol block at login, an remove it at logout.

This is a recipe, I tried it briefly (on a xubuntu VM) and it should work as well as it does on a mac.
In file /etc/gdm/PreSession/Default, replace the last line "exit 0" with this:
SCIp='127.0.0.1'
CLIPort='9090'
LOGGER=/usr/bin/logger
NC=/bin/nc
$LOGGER -i "loginhook"
/bin/echo srvrpowerctrl setblock Logon_block viacli | nc -w 3 $SCIp $CLIPort
exit 0
In file /etc/gdm/PostSession/Default, eplace the last line "exit 0" with this:
SCIp='127.0.0.1'
CLIPort='9090'
LOGGER=/usr/bin/logger
NC=/bin/nc
$LOGGER -i "logouthook"
/bin/echo srvrpowerctrl clearblock Logoff_clearing_block viacli | $NC -w 3 $SCIp $CLIPort
exit 0

If you're interested, I suggest you check out the srvPowerControl thread in 3rd Party Plugins and ask for assistance there.

HTH

Ausir
2009-09-27, 10:57
Thank you for the answer. I'll check the SvrPowerControl-thread, although it was 94 pages long or so ;)

philly4
2009-09-27, 11:56
What I'm hoping to get working is a fix with svrpowerctrl. There is an option: "Optional action to take while not idle:" that lets you run a command when the server is active. Is there a command that will simulate a keystroke or mouse movement. I tried "gnome-screensaver-command -p" but it doesn't seem to work. Any other simple commands that might actually work, or is there more to just typing in that command to get it to work?

Declan Moriarty
2009-09-27, 14:28
You might want to look at Windows: Prevent Standby plugin. The reason it is for windows is that it uses the Win32::API with the kernel32 command. If you change this command in the Plugin.pm file in the C:\Program Files\SqueezeCenter\server\Slim\Plugin\PreventStan dby directory (this will be in the ../SqueezeCenter/server/Slim/Plugin/PreventStandby directory on Ubuntu). With the SqueezeCenter directory being where programs are normally stored in Ubuntu. If you cange the Win32::API command to a linux command to switch off power management you should be OK. Probably the best thing to do is to copy the PreventStandby directory to something like PreventStandbyLinux and make the change to the Plugin.pm file. Note that there is an install.xml file with xml detailing the plugin name etc. One of the first lines in this file is an id tag that looks like this:-

<id>BFACABFD-6334-4743-95BA-43A60E159560</id>

How this is generated I don't know. Would a coppied plugin break if this line ws coppied? If one got rid of it would the plugin still work? How was it generated in the first place?

The plugin was wirtten by Julian Neil. He might be able to give pointers on these matters. If you did copy the plugin it would be polite to add a revision in the header of the Plugin.pm file stating that the plugin ws adapted for Ubuntu.

Note that the last line of the install.xml file has:-

<targetPlatform>Windows</targetPlatform>

Note this is the second to last line as the last line has the </extension> tag on it!

You will need to remove Windows from the targetPlatform tag and replace with Linux.

This presupposes that there is a linux bash shell command to switch off suspend mode!

epoch1970
2009-09-28, 03:09
Guys, gharris999, the owner, manager and night watchman of the srvPowerControl thread is your man. That thread in 1/3 party plugin should concentrate all the use-cases, in addition to direct questions/bug reports.
(Gharris999 also wrote a ReallyPreventStanby program that susperseeds PreventStandby, AFAIK.)