Next Previous Contents

4. The distccd Server

The distccd server may be started either from a super-server such as inetd, or as a stand-alone daemon. distccd does not need to run if

The --listen and --allow options can be used to restrict connections to authorized clients. The --jobs and --nice options can be used to prevent remote compilations imposing too much load on the volunteer machine.

distccd can be started by any user. If started by root, it changes to either the user specified by the --user option, or the user called "distcc", or "nobody".

distccd does not have a configuration file; it's behaviour is controlled only by command-line options and requests from clients.

distccd logs messages to syslog's daemon facility by default, which normally writes to /var/log/daemon or /var/log/messages. Log messages can be sent to a different file using the --log-file option, which is generally slightly faster than using syslog.

4.1 Starting distccd

Starting a Standalone Server

The generally recommended method for running distccd is to run it as a standalone server. distccd will listen for network connections and fork several child processes to serve them.

If you installed distcc using a packaged version you may be able to start the server using the standard mechanism for your operating system, such as service distcc start or /etc/init.d/distcc start.

To start distccd as a standalone service, run a command like this either as root or an ordinary user:

# distccd --daemon

Starting from init or daemontools

distccd may be run as a standalone daemon under the control of another program like init(8) or daemontools. The super-server starts distccd when the system boots, and whenever it exits.

distccd should be started just as for a standalone server, except that the --no-detach option should be used so that the super-server can monitor it.

For example, to add distccd as a process to Linux sysvinit, add this line to /etc/inittab

dscc:2345:respawn:/usr/local/bin/distccd --verbose --no-detach --daemon

Starting from inetd

distccd may be started from a network super-server such as inetd or xinetd. In this case inetd listens for network connections and invokes distccd when one arrives.

This is slightly less efficient than running a standalone distccd daemon and distccd is not able to regulate the number of jobs accepted. However it does centralize configuration and access control for all network services.

For traditional Unix inetd, a line like this can be added to /etc/inetd.conf:

distcc stream tcp nowait.1000 root /usr/local/bin/distccd distccd --inetd

inetd imposes a limit on the rate of connections to a service to protect against accidental or intentional overuse. The default in Linux NetKit inetd is 40 per minute, which can be too low for distccd. The .1000 option raises the limit to 1000 per minute.

4.2 distccd Options

--help

Explains usage of the daemon and exits.

--version

Shows the daemon version and exits.

-j, --jobs JOBS

Sets a limit on the number of jobs that can be accepted at any time. Currently ignored in inetd mode.

-N, --nice NICENESS

Makes the daemon more nice about giving up the CPU to other tasks on the machine. NICENESS is a value from 0 (regular priority) to 20 (lowest priority). This option is good if you want to run distccd in the background on a machine used for other purposes.

-p, --port PORT

Set the TCP port to listen on. (Standalone mode only.)

--listen ADDRESS

Instructs the distccd daemon to listen on the IP address ADDRESS. This can be useful for access control on dual-homed hosts.

-P, --pid-file FILE

Save daemon process id to file FILE.

--user USER

If distccd gets executed as root, change to user USER.

-a, --allow IPADDR[/MASK]

Instructs distccd to only accepts connections from the IP address IPADDR. A subnet mask can be supplied optionally after a trailing slash, e.g. 192.168.0.0/24.

--verbose

Include debug messages in log.

--no-detach

Do not detach from the shell that started the daemon. This may be useful when running distccd from a system such as daemontools that manages daemons after they start.

--no-fork

Don't fork children for each connection, to allow attaching gdb. Don't use this if you don't understand it!

--no-fifo

Send input to the compiler by writing to a temporary file, rather than using a pipe. This is required when the server's temporary directory is on NFS, on at least some machines. It may be faster in some circumstances, but probably is not.

--log-file=FILE

Send messages to file FILE instead of syslog. Logging directly to a file is significantly faster than going via syslog and is recommended.

--log-stderr

Send log messages to stderr, rather than to a file or syslog. This is mainly intended for use in debugging.

--inetd

Serve a client connected to stdin/stdout. As the name suggests, this option should be used when distccd is run from within a super-server like inetd. distccd assumes inetd mode when stdin is a socket.

--daemon

Bind and listen on a socket, rather than running from inetd. This is used for standalone mode. distccd assumes daemon mode at startup if stdin is a tty, so --daemon should be explicitly specified when starting distccd from a script or in a non-interactive ssh connection.

4.3 distccd Exit Codes

As for distcc exit .

4.4 distccd Environment Variables

DISTCC_SAVE_TEMPS

If set to 1, temporary files are not deleted after use. Good for debugging or if your disks are too empty.

Note that DISTCC_LOG does not affect the log destination for the server.

4.5 Terminating distccd

To shut down a standalone server, send a SIGTERM signal to the parent process. The most reliable way to do this from a script is to use the --pid-file option to record its process ID.

Shutting down the server may interrupt any compilation jobs which are in progress and cause warnings on any clients that are using the server. The client will reissue the jobs, so shutting down the server should not cause a build to fail.

To shut down a server run from inetd, init or another program, see the manual for that program.


Next Previous Contents