Helix Core Server Administrator Guide: Fundamentals (2019.2)

Running from inetd

Under a normal installation, the Perforce service runs on Linux as a background process that waits for connections from users. To have p4d start up only when connections are made to it, using inetd and p4d -i, add the following line to /etc/inetd.conf:

p4dservice stream tcp nowait username /usr/local/bin/p4d p4d -i -r p4droot

and then add the following line to /etc/services:

p4dservice nnnn /tcp

where:

  • p4dservice is the service name you choose for this Helix server
  • /usr/local/bin is the directory holding your p4d binary
  • p4droot is the root directory (P4DROOT) to use for this Helix server (for example, /usr/local/p4d)
  • username is the UNIX user name to use for running this Helix server
  • nnnn is the port number for this Helix server to use

The "extra" p4d on the /etc/inetd.conf line must be present; inetd passes this to the OS as argv[0]. The first argument, then, is the -i flag, which causes p4d not to run as a background process, but rather to serve the single client connected to it on stdin/stdout. (This is the convention used for services started by inetd.)

This method is an alternative to running p4d from a startup script. It can also be useful for providing special services; for example, at Perforce, we have a number of test servers running on UNIX, each defined as an inetd service with its own port number.

There are caveats with this method:

  • inetd may disallow excessive connections, so a script that invokes several thousand p4 commands, each of which spawns an instance of p4d via inetd can cause inetd to temporarily disable the service. Depending on your system, you might need to configure inetd to ignore or raise this limit.
  • There is no easy way to disable the server, since the p4d executable is run each time; disabling the server requires modifying /etc/inetd.conf and restarting inetd.
  • To use Helix server with this license, you will need to request a server license that does not specify a port. Contact Perforce licensing for more information.
Note

For information about using systemd to launch services and daemons at boot time, see the Support Knowledgebase article, Example systemd Perforce Service File.