I started from scratch and used Net:: Daemon (I am no coder, but the only language I seem to grok beyond javascript is perl). I set a single instance of it, with a "run" thread that gets polled by the linux watchdog, and a "loop" thread that looks every minute or so for the status of nfs, afp, smb, sbs, console sessions, network traffic, and recently I added backuppc. The "loop" is slow and none too bright, and painfully returns a vote (0/1) for suspend or keep-alive. Then that status is repeated at will by the "run" thread when it receives a network connection. The standard linux watchdog runs on its own, and queries the "run" thread via the "test-binary" facility (see the man for watchdog.) I use the wachdog because I want the machine to reboot itself when things go awry. (But if the kernel thawing process fails at wake, there is a chance the watchdog won't operate. With the right kernel and amount of testing, you can get a reliable system even with dubious hardware.)
In addition the "run" thread reaps flags which are placed in a specific directory, and can force it to respond something other than what the "loop" wants. So I can block the machine from going to sleep (I use that when backuppc starts a job, for example), or have it reboot cleanly (without being killed halfway in the process by an angry watchdog.) This last feature more or less requires the "loop" to be stateless, it rediscovers the situation all over at each run, until the machine sinks into sleep (and it restarts from wherever it was at wake time.) Suddenly, debugging things like auto-switching the SB players to mySB.com when the server goes down (and grabbing them back when up) becomes a serious affair. For suspend I tweaked the system a lot. I initially used the pm-sleep/pm-suspend suite of scripts (made for laptops) and scrubbed all I could to make it faster and leaner. I finally did away with it and call "s2ram -f" directly from the watchdog test-binary. The machine is up and operates in under 10 secs (from the press on the SB IR remote to a song to start). I think you want to use linux 2.6.26 at least. I am currently running a system like this with 2.6.28. My parents server work like this, they use it every day and it has an uptime that seems only limited by the frequency of power or maintenance events (I've seen > 150 days) I'm sorry but I can't begin to describe the uglyness of that code. I could give it to you but I doubt that would make any good. But feel free to PM if you like puzzles. (for samba and afp I do an "lsof" to see if there are opened files within the network shares. works ok.) -- epoch1970 ------------------------------------------------------------------------ epoch1970's Profile: http://forums.slimdevices.com/member.php?userid=16711 View this thread: http://forums.slimdevices.com/showthread.php?t=72608 _______________________________________________ unix mailing list [email protected] http://lists.slimdevices.com/mailman/listinfo/unix
