Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to use supervisord to control postfix. The usual method is to specify a command which starts the daemon, I use postfix -c /etc/postfix start. The postfix man page says that to stop you replace start with stop in the above command.

I do not see a way of specifying another command to stop a daemon, just a signal. The master manpage says that the TERM signal will function as if postfix abort was used but is silent on shutting down gracefully via a signal.

Also, the start/stop method of the first paragraph is tricky as far as supervisord is concerned. The script performs a bunch of checks and then invokes master, qmgr and pickup with master as the process group leader. Thus, supervisord has a handle on a useless PID (one the script was running as) and cannot therefore use that PID to stop the daemon. What it should have a handle to is the master process.

How far I've got:

process_name    = master
priority        = 5
directory       = /etc/postfix
command         = /usr/sbin/postfix -c /etc/postfix start
startsecs       = 0
user            = root
stopsignal      = INT

This starts postfix but cannot stop it.

share|improve this question

2 Answers 2

Turns out that it is simpler to use something like Monit to monitor daemons:

Monit is a free open source utility for managing and monitoring, processes, programs, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.

You can use Monit to monitor daemon processes or similar programs running on localhost. Monit is particular useful for monitoring daemon processes, such as those started at system boot time from /etc/init.d/. For instance sendmail, sshd, apache and mysql.

enter image description here

share|improve this answer

My solution is to write a wrapper script named postfix.sh as follows:

# call "postfix stop" when exiting
trap "{ echo Stopping postfix; /usr/sbin/postfix stop; exit 0; }" EXIT

# start postfix
/usr/sbin/postfix -c /etc/postfix start
# avoid exiting
sleep infinity   

After that, modify supervisord.conf:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.