"To be a warrior is not a simple matter of wishing to be one. It is rather an endless struggle that will go on to the very last moment of our lives. Nobody is born a warrior, in exactly the same way that nobody is born an average man. We make ourselves into one or the other." --Kokoro
NOTE: all links in this document refer to external sites which are beyond my control. The documents linked retain the copyright of their respective authors. I disclaim all liabilites for the content presented on the other sites.
Introduction
Postfix is a modular, high-performance and relatively secure mail transport agent for Unix written and maintained by Wietse Z. Venema. It is aimed as replacement for sendmail and tries to mimic its user-visible behaviour closely.
Daemontools is a collection of tiny useful tools that monitor and manage services (daemons) written by Daniel J. Bernstein. If you’re familiar with SysV init and inittab, daemontools do a similar job, but do not have a notion of run levels, but are purely service oriented.
Postfix is usually run from your system startup files, either from a rc file (BSD, some Linux variants) or via SysV-style init (SysV and some other Linux variants). Although Postfix’ master process has proven reliable on a couple of machines in over two years’ time, you may want to start Postfix from daemontools.
Setting up a/servicedirectory entry for Postfix
I’m assuming that you have already installed daemontools as written in Dan’s document. Make sure svscan is started properly at reboot time and it is running before you do the following.
Then, to start Postfix from daemontools, do the following:
Create a directory where you want your run file in. Example:
1
mkdir/etc/postfix/service
Create a file /etc/postfix/service/runwhich contains the following (you may want to adjust the PATH to your local needs):
If postfix has been started outside of daemontools, postfix stop is invoked before postfix is started. This makes sure you can control Postfix with svc. It may however interrupt service for a couple of seconds.
svscan will start Postfix in a few seconds’ time.
You cannotusepostfix stop,postfix drainandpostfix startto manage Postfix. In case you stop Postfix this way, daemontools will think Postfix has crashed and restart it. If you start Postfix this way, it will either be refused because svscan already started Postfix or, if svscan is started later, supervise will loop and Postfix is not supervised. Also see below.
You canusepostfix flushandpostfix checkalthough the latter is done automatically before startup as well.
You canusepostfix reloadsafely.
To stopPostfix, use:svc -d /service/postfixmnemonic: -d for down
To startPostfix, use:svc -u /service/postfixmnemonic: -u for up