Run Perforce P4D server as a daemon

Nov 15, '04 09:40:00AM

Contributed by: Anonymous

Here's how I set up Perforce's P4D server as a daemon on OSX (10.3.6). Finding this info on Google is, well, impossibl -- so I thought it handy to have some reference to it here, so that people would be able to find it more easily. The Perforce site seems lacking in documentation as far as I can tell. First, as root, create a file in /etc/xinetd.d called perforce, with the following contents:

service perforce
{
    disable = no
    flags       = REUSE
    socket_type = stream
    wait        = no
    user        = root
    server      = /usr/local/bin/p4d
    server_args = -i -L /var/log/p4d.log -r /usr/local/p4root
}

The contents of my xinet.d directory looks like:

G5:~ mdavis$ cd /etc/xinetd.d/
G5:/etc/xinetd.d mdavis$ ls
auth            daytime-udp     ftp             shell           tftp
bootps          echo            login           smb-direct      time
chargen         echo-udp        nmbd            smbd            time-udp
chargen-udp     eppc            ntalk           ssh
comsat          exec            perforce        swat
daytime         finger          printer         telnet
You can change the path to the P4D binary and, of course, the log file and the Perforce root. I couldn't get any other user other than root to work, even when I created a "p4" user in NetInfo along with a group all based on the copying the settings from mysql. Dunno why, probably because I'm not a UNIX guru. You also need to edit /etc/services as follows:
#netview-aix-6   1666/udp   # netview-aix-6
perforce        1666/tcp   # Perforce Server
#netview-aix-6   1666/tcp   # netview-aix-6
Of course, I'm using the default port, but you could use any port you like providing p43 knows about it (via server_args). You'll get a log file which you can see with tail -f command, or in Console.app at /var -> log -> p4d -> log. When you're done, either reboot or restart xinetd like this:
G5:/etc/xinetd.d mdavis$ ps -ax | grep xinetd
  402  ??  Ss     0:00.15 xinetd -inetd_compat -pidfile /var/run/xinetd.pid

G5:/etc/xinetd.d mdavis$ sudo kill -HUP 402
Enjoy!

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20041112174525470