Letting the server machine sleep (macOS)

on my server machine i’m not seeing anything listed under “pmset -g sched” on behalf of the channels DVR server, despite there being several recordings scheduled.

is letting the server machine sleep unsupported?

thanks

rob

Sleep is currently unsupported. See Mac Mini

thanks, my search-fu is weak. i was going to ask if it’s normal that the machine does not wake when you try to access the http server but unsupported is unsupported :slight_smile:

rob

We haven’t really spent any time on it. I’m not sure if Wake-on-LAN is supposed to work automatically, or if there’s something we need to do on our end to enable it.

i gotcha - i just put my 2 cents in in another sleep related thread.

i haven’t read the developer docs but my crude understanding of Bonjour Sleep Proxy is that when a machine broadcasts an ARP looking for a sleeping machine, the appleTV or airport responds to the ARP and also sends a WOL packet to the mac address in question. so it’s somewhat automatic, but the question is if you have to do something to register the machine in the first place. doing some cursory reading it appears that advertising a service via bonjour should be enough and IIRC you do have a bonjour toggle switch in the settings… so i’m not sure why my http request did not wake up the machine. anyway for now i’ll turn off sleep - i think i had a completely corrupted recording overnight due to the machine falling asleep midway.

this is old but is hopefully still relevant: http://stuartcheshire.org/SleepProxy/index.html

rob

also - despite the bonjour advertisement check box being ticked, i don’t see the service being advertised (dns-sd -B _http._tcp only shows eyeTV, my printer, etc. as advertising services).

rob

dns-sd -B _channels_dvr

ok that shows. thought -B with no argument would show all services advertised but i guess it defaults to http. i copied and pasted the wrong line into that message.

rob

I was able to find an API to prevent macOS from going to sleep while the DVR is busy recording (IOPMAssertionCreateWithName). This will be part of the next build, and can be verified using pmset -g assertions.

I also found the API that corresponds to pmset -g sched (IOPMSchedulePowerEvent). However, this API requires admin privileges, and since the DVR runs as a regular user it doesn’t work for us.

cool!! that’s too bad about -g sched, i think that other program is definitely using that to cause the machine to wake up a few minutes before a recording begins if asleep.

is the next scheduled recording time exposed anywhere in an API or web page? i’m not opposed to writing my own helper script which runs as root and scrapes the next recording time and calls pmset -g sched

rob

Okay, I found a somewhat simple way for the DVR to be able to invoke pmset. Run the following commands in Terminal:

cd ~/channels-dvr
curl -fo install.sh https://getchannels.com/dvr/install-darwin.sh
./install.sh --wake-helper

It will ask for your password, and setup a sudo helper for the DVR.

The next build of the DVR will use this helper to add the appropriate wakeorpoweron events.

1 Like
SUCCESS: The wake-helper is installed.

if you don’t mind can you post here when the new build is pushed so i can try it out right away?

thanks

rob

1 Like

Here’s a pre-release build you can try out. Let me know how it works out for you.

In Terminal, run:

curl -XPUT http://127.0.0.1:8089/updater/check/2017.04.24.2217

just installed it - should i see a wakeorpoweron event in pmset -g sched?

rob

Yes you should…

hmm i don’t see an entry there, here is what i see in the log:

2017/04/24 15:29:41 [SYS] Downloading new version v2017.04.24.2217
2017/04/24 15:30:12 [SYS] Update downloaded and verified successfully.
2017/04/24 15:30:12 [SYS] Shutting down for upgrade from v2017.04.20.2223 to v2017.04.24.2217
2017/04/24 15:30:12 [DVR] Recording engine stopped.
2017/04/24 15:30:14 [SYS] Starting Channels DVR v2017.04.24.2217 (darwin-x86_64) in /htpc/channels-dvr/data
2017/04/24 15:30:15 [HDR] Found 1 devices
2017/04/24 15:30:16 [SYS] Started HTTP Server
2017/04/24 15:30:27 [DVR] Recording engine started in /Volumes/media_5tb/ChannelsDVR
2017/04/24 15:30:27 [SYS] Bonjour service running for dvr-htpc2.local. [172.18.1.15]
2017/04/24 15:30:27 [SYS] Removing old update 2017.04.17.1856
2017/04/24 15:30:27 [DVR] Waiting 3h26m32.913702936s until next job 1493085420-7 Jeopardy!
2017/04/24 15:30:27 [SYS] Created database snapshot: backup-20170424.153027
2017/04/24 15:30:38 [IDX] Pruned 536 expired airings from USA-OTA94618 in 1.132015847s.

of course this is the machine running 10.9.5, which i suppose could have something to do with it. i suppose its safe for me to upgrade now…

the helper does work - i can “sudo /usr/bin/pmset” without entering my password, so it seems the dvr backend did not run pmset?

Hrm, works for me on 10.11 and 10.12.

Can you check to see if the installed file looks the same as this:

$ sudo cat /etc/sudoers.d/channels-dvr
Cmnd_Alias DVR_PMSET_SCHEDULE = /usr/bin/pmset schedule wakeorpoweron * com.getchannels.dvr
Cmnd_Alias DVR_PMSET_CANCEL = /usr/bin/pmset cancel wakeorpoweron * com.getchannels.dvr
ALL ALL=(root) NOPASSWD: DVR_PMSET_SCHEDULE, DVR_PMSET_CANCEL

Oh I bet on 10.9 it’s not using that file at all… Check to see if this matches too:

$ sudo tail -1 /etc/sudoers
#includedir /private/etc/sudoers.d

/etc/sudoers.d/channels-dvr looks like what you’ve posted. /etc/sudoers does not have the includedir directive. i could add it and see what happens…

rob