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, an organization might have a several test servers running on UNIX, each defined as an inetd service with its own port number.

There are caveats with this method:

  • inetd can disallow excessive connections, so a script that invokes several thousand p4 commands, each of which spawns a p4d server via inetd, might 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 because 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 need to request a server license that does not specify a port. Contact https://www.perforce.com/support/request-support.
Note

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