[p4] p4d -- able to survive long "laptop sleep"?

jab jab at pobox.com
Thu Mar 17 06:00:13 PST 2005


There is another way.

Look at "p4d -i" as an alternate route, in which you can have an 
instance of
"p4d" started by inetd ONLY when a TCP request comes into port 1666. 
That
way, "p4d" is running only when it's processing a command, and 
otherwise the
server isn't just inactive - it isn't running.

For a lightly used server, on a laptop or the like, this works 
remarkably well.
If memory serves, I needed to touch: /etc/services, /etcinetd.conf, and 
I needed
to write a small shell script that ran "p4d -i" with the right 
arguments.

My entry for /etc/inetd.conf is:
	p4-1666 stream  tcp     nowait  root /usr/local/bin/p4inet p4d p4-1666
My entry for /etc/services is:
	p4-1666     1666/tcp
My version of /usr/local/bin/p4inet was:
> #!/bin/sh
>
> P4DEBUG="server=1"
> export P4DEBUG
>
> case $1 in
> p4-1666) R=/p4/p4-root; S=/p4/p4-root/p4d ;;
> p4-1777) R=/p4/p4-playpen; S=/p4/p4-playpen/p4d ;;
> *)      exit ;;
>
> esac
>
> export P4ROOT=$R
> exec $S -v$P4DEBUG -i 2>> $P4ROOT/LOG

PLEASE don't take this as a complete set of instructions; read the 
manual.
But this strategy's been really handy for me, for years, on Unix/Linux 
laptops.

And I haven't found a better Unix laptop than my Apple Powerbook.

	-Jeff Bowles

On Mar 17, 2005, at 12:06 AM, Peter Steiner wrote:

> On Wed, 16 Mar 2005 11:17:53 -0800, Mark Harrison wrote:
>
>> I'm setting up p4 for somebody whose primary hardware
>> platform will be an apple powerbook.
>>
>> p4d will be fun from init.d at startup.
>
> Does the powerbook run OS X? Then you should perhaps consider using a
> StartupItem. My very simple setup (a more sophisticated one is on
> http://www.piap.com/faq/p4_setup.html):
>
> $ ls -l /Library/StartupItems/Perforce/
> total 16
> -rwxrwxr--  1 root  admin  489 20 Nov  2003 Perforce
> -rw-rw-r--  1 root  admin  154 20 Nov  2003 StartupParameters.plist
>
> /Library/StartupItems/Perforce/Perforce:
> ==================
> #!/bin/sh
>
> ##
> # Perforce Server
> ##
>
> . /etc/rc.common
>
>
> start_p4d()
> {
>      /usr/local/bin/p4d -q -J /data/perforce/journal \
>          -L /data/perforce/log -r /data/perforce &
> }
>
> stop_p4d()
> {
>      killall "p4d"
> }
>
> StartService ()
> {
>      ConsoleMessage "Starting Perforce Server"
>      start_p4d
> }
>
> StopService ()
> {
>      ConsoleMessage "Stopping Perforce Server"
>      stop_p4d
> }
>
> RestartService ()
> {
>      ConsoleMessage "Restarting Perforce Server"
>      stop_p4d
>      sleep 1
>      start_p4d
> }
> ==================
>
> /Library/StartupItems/Perforce/StartupParameters.plist
> ==================
> {
>    Description     = "Perforce server";
>    Provides        = ("Perforce Server");
>    Requires        = ("Disks", "Network");
>    OrderPreference = "None";
> }
> ==================
>
>
>>
>> The powerbook will sleep whenever the screen is closed.
>> Will this cause any kind of known problems for p4d?
>
> I have a p4d running on my powerbook for more than a year and p4d never
> failed me. And I almost never shut the powerbook down, I usually just
> close the lid...
>
> Regards, Peter
> -- 
>     _   _        Peter Steiner <peter.steiner at hugwi.ch>
>   / /_/ /        Hug-Witschi AG <http://www.hugwi.ch/>
>  /  _  /         Electronic Engineering
> /_/ /_/  _   _   Auriedstrasse 10
>    / / / / / /   CH-3178 Boesingen
>   / /_/ /_/ /    Tel  +41 31 740 44 44
>  /_ _ _ _ _/     Fax  +41 31 740 44 45
>
> _______________________________________________
> Come to the 2005 Perforce User Conference, April 14 & 15 in Las Vegas.
> Learn more: http://www.perforce.com/conf
>
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user
>




More information about the perforce-user mailing list