Opened 13 years ago

Last modified 5 years ago

#33719 new enhancement

keep machines from sleep during port building

Reported by: drechsel@… Owned by: macports-tickets@…
Priority: Normal Milestone: MacPorts Future
Component: base Version: 2.0.4
Keywords: Cc: ryandesign (Ryan Carsten Schmidt), nonstop.server@…, cooljeanius (Eric Gallager), jpenney (Jason Penney)
Port:

Description

Frequently I noticed that my iMac G5 will go to sleep during a time extensive build (gcc45 at the moment).

I googled and found some other people with that problem - and an easy solution:

#!/bin/bash
pmset noidle &
<<<... do the work here ...>>>
kill %pmset

Wouldnt it be smart to put the "noidle" command at the very beginning of any build script - and the "kill %pmset" at the very ending? I'd like the iMac to do the building - and then go to sleep after it's finished if nothing else is to do.

Change History (14)

comment:1 Changed 13 years ago by neverpanic (Clemens Lang)

Cc: cal@… added
Milestone: MacPorts Future
Port: all removed

comment:2 Changed 13 years ago by mf2k (Frank Schima)

Component: portsbase

comment:3 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added

Seems like a good suggestion to me.

On the mailing list, some people expressed the opinion that they would want to opt out of this behavior. So we might consider adding a macports.conf option.

Other users were worried this would require root / sudo to use, but that does not appear to be the case.

comment:4 Changed 13 years ago by raimue (Rainer Müller)

At the moment, we have several code paths where this action would be required. Also, there is currently no handling when port fails or is interrupted by the user, so we cannot guarantee that we can restore the old behavior in any case.

I don't think adding this to each single build would be enough. When the first port finishes the computer could go to sleep immediately as we kill this pmset noidle process, right?

I would recommend to just use this in a custom wrapper around the port command for now.

comment:5 Changed 13 years ago by drechsel@…

I don't think that after killing the pmset process the machine will go to sleep immediately. My experience is that it depends on the "energy saving" settings - that means that it normally will wait the number of minutes set and then go to sleep.

I'd like an option which makes the machine behave like raimue says: 'shutdown -s now' after the build was finished (successfully or not), so in the case I know I will not attend the building machine all the time, I get the most energy saving possible. Play a sound or something when finished would be another nice option, by the way.

If building a port fails, the "kill pmset" command could be executed nevertheless - as an error message is displayed now.

comment:6 in reply to:  5 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to drechsel@…:

I'd like an option which makes the machine behave like raimue says: 'shutdown -s now' after the build was finished (successfully or not), so in the case I know I will not attend the building machine all the time, I get the most energy saving possible.

In the Terminal where the port process is running, type your shutdown command. (I use a sleep command myself.) It will run when the port command is finished. I personally use a shell script that does:

osascript -e 'tell app "System Events" to sleep' &

I save this script in my scripts folder as "sleepmac". If you want shutdown instead of sleep, use:

osascript -e 'tell app "System Events" to shut down' &

I save this script as "shutdownmac".

Or you could use a new terminal and do "waitport && shutdownmac".

Play a sound or something when finished would be another nice option, by the way.

I used a shell function (a wrapper around "port") to do this. But MacPorts 1.9.0 largely broke it, since it won't work when you use "sudo", which since MacPorts 1.9.0 you pretty much have to. (I used to have non-root MacPorts installations where that wasn't necessary.)

comment:7 Changed 13 years ago by nonstop.server@…

Cc: nonstop.server@… added

Cc Me!

comment:8 Changed 12 years ago by bfrancis9898@…

I am not sure that this is a feature that needs to be in the program because power management is generally a system function rather than an application function. If some apps are telling the system to stay awake and others are commanding it to sleep it could get interesting. I use a menu bar app called Caffeine that is free, works well, and will keep my system awake until I click the coffee cup icon. I have a visual cue that the system is in "stay awake" mode and can run builds or do anything else that does not like or benefit from the system going to sleep.

comment:9 Changed 11 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:10 Changed 10 years ago by jpenney (Jason Penney)

I'm not sure when it was added (possibly Mountain Lion?), but there's a command line tool for this scenario in OS X:

$ caffeinate -h
usage: caffeinate [-disu] [-t timeout] [command] [arguments]

If you pass it a command and arguments, it prevents the system from sleeping until the command exits. I use this all the time with macports:

$ caffeinate sudo port upgrade outdated

comment:11 Changed 10 years ago by jpenney (Jason Penney)

Cc: jpenney@… added

Cc Me!

comment:12 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)

caffeinate appears to have been introduced in OS X 10.8 Mountain Lion, yes.

comment:13 Changed 5 years ago by jmroot (Joshua Root)

I'm not convinced we need to do anything here with caffeinate available on all recent systems, but if someone is inclined to add the feature, this document explains how: https://developer.apple.com/library/archive/qa/qa1340/_index.html

comment:14 Changed 5 years ago by neverpanic (Clemens Lang)

Cc: neverpanic removed
Note: See TracTickets for help on using tickets.