* qpsmtpd-forkserver on Mac OS X
@ 2006-06-05 8:58 Michael Glaesemann
2006-06-06 15:57 ` Gerrit Pape
0 siblings, 1 reply; 8+ messages in thread
From: Michael Glaesemann @ 2006-06-05 8:58 UTC (permalink / raw)
Hello!
I'm trying to get qpsmtpd-forkserver[1] to start automatically on
server restart.
Mac OS X 10.4.6 (Intel Mac Mini)
runit-1.5.1
qpsmtpd-0.32 -- An easily extensible smtp server written in Perl.
From what I can tell, the qpsmtpd installation is working fine, and
the runit installation is okay. However, using the two together
doesn't seem to work. Details of my configuration are below. I've
googled and looked through the documentation on using runit with
qpsmtpd [2] and runit with launchd [3], but am at a loss as to what I
have misconfigured.
I've posted this to the runit mailing list first, as it appears that
my qpstmpd installation is okay. If it looks like it's a qpstmpd
configuration problem, I'll definitely ask there as well.
Any hints or suggestions on what else I might check in my
configuration, or where I might find additional information is
appreciated. If there's any information about the setup I can provide
to make it easier to diagnose, please let me know.
Thanks!
Michael Glaesemann
grzm seespotcode net
[1](http://smtpd.develooper.com/)
[2](http://wiki.qpsmtpd.org/runit)
[3] (http://smarden.org/runit/useinit.html#macosx)
-----
I can run the qpstmpd-forkserver from the command line using
sudo /usr/local/qpsmtpd/qpsmtpd-forkserver --detach --user www --port 25
After launching the qpsmtpd-forkserver from the command line, I can
connect to the smtp server via telnet:
$ telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 wilde.local ESMTP qpsmtpd 0.32 ready; send us your mail, but not
your spam.
The server also delivers mail as expected when launched from the
command line.
The qpsmtpd wiki gives instructions[2] on how to configure qpsmtpd-
forkserver with runit. Here's /var/service/qpsmtpd/run
$ cat /var/service/qpsmtpd/run
#!/bin/bash
unset PERL_UNICODE
/usr/local/qpsmtpd/qpsmtpd-forkserver --detach --user www --port 25
$
I've installed runit according to the instructions, including the
modifications for installation on Mac OS X (modifications to src/conf-
ld and src/Makefile)
Installation appeared to go fine. I saw no errors at the end of the
installation script.
$ ls -la /sbin/runsvdir-start
-rwxr-x--- 1 root wheel 554 Jun 5 11:17 /sbin/runsvdir-start
$ ls -la /var/service/qpsmtpd/
total 8
drwxr-xr-x 5 root wheel 170 Jun 5 17:19 .
drwxr-xr-x 3 root wheel 102 Jun 5 11:24 ..
drwxr-xr-x 3 root wheel 102 Jun 5 17:20 log
-rwxr-xr-x 1 saiadmin wheel 99 Jun 5 13:08 run
drwx------ 8 root wheel 272 Jun 5 17:52 supervise
/var/service/qpsmtpd/supervise was created automatically and I can
see that the modification time is incrementing. This is why I think
runit is properly installed.
$ cat /var/service/qpsmtpd/run
#!/bin/bash
unset PERL_UNICODE
/usr/local/qpsmtpd/qpsmtpd-forkserver --detach --user www --port 25
wilde:/usr/local/qpsmtpd saiadmin$
$ cat /Library/LaunchDaemons/org.smarden.runit.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.smarden.runit</string>
<key>ServiceDescription</key>
<string>runsvdir - starts and monitors a collection of runsv
(8) processes</string>
<key>QueueDirectories</key>
<array>
<string>/var/service</string>
</array>
<key>OnDemand</key>
<false/>
<key>Disabled</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/sbin/runsvdir-start</string>
</array>
</dict>
</plist>
$
When org.smarden.runit.plist is loaded (either manually using
launchctl or automatically on server restart), qsmtpd-forkserver
doesn't appear to work. However, something is definitely running on
port 25:
$ netstat -atn | grep -e '\.25'
tcp4 0 0 *.25 *.*
LISTEN
$
Connecting via telnet fails:
$ telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
$
I don't see anything in /var/log/system.log (where launchd problems
are logged) or /var/log/mail.log (the qpsmtpd log). When using
launchd/runit, nothing is logged to /var/log/mail.log at all. (When
run from the command line, mail.log contains information about
connections to the smtp server.)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: qpsmtpd-forkserver on Mac OS X
2006-06-05 8:58 qpsmtpd-forkserver on Mac OS X Michael Glaesemann
@ 2006-06-06 15:57 ` Gerrit Pape
2006-06-07 3:36 ` Michael Glaesemann
0 siblings, 1 reply; 8+ messages in thread
From: Gerrit Pape @ 2006-06-06 15:57 UTC (permalink / raw)
On Mon, Jun 05, 2006 at 05:58:17PM +0900, Michael Glaesemann wrote:
> I'm trying to get qpsmtpd-forkserver[1] to start automatically on
> server restart.
>
> Mac OS X 10.4.6 (Intel Mac Mini)
> runit-1.5.1
This may be another problem, independent from what you report: AFAIK
the poll() implementation of Mac OSX 10.4/Intel is broken, and doesn't
work for named pipes. runit (or better daemontools' iopause()) has an
alternative implementation using select(), but this isn't chosen while
building as poll() is available, but broken.
> I can run the qpstmpd-forkserver from the command line using
>
> sudo /usr/local/qpsmtpd/qpsmtpd-forkserver --detach --user www --port 25
I guess you get a prompt back after this command because of the --detach
option.
> The qpsmtpd wiki gives instructions[2] on how to configure qpsmtpd-
> forkserver with runit. Here's /var/service/qpsmtpd/run
>
> $ cat /var/service/qpsmtpd/run
> #!/bin/bash
> unset PERL_UNICODE
> /usr/local/qpsmtpd/qpsmtpd-forkserver --detach --user www --port 25
> $
The service daemon must not background (or 'daemonize') when supervised
by runit, but must run in the foreground. Try to remove the --detach
option.
> When org.smarden.runit.plist is loaded (either manually using
> launchctl or automatically on server restart), qsmtpd-forkserver
> doesn't appear to work. However, something is definitely running on
> port 25:
Maybe you didn't stop the daemon you started before from the command
line, and which detached from the terminal and process tree, and now
still listens on the port.
> I don't see anything in /var/log/system.log (where launchd problems
> are logged) or /var/log/mail.log (the qpsmtpd log). When using
> launchd/runit, nothing is logged to /var/log/mail.log at all. (When
> run from the command line, mail.log contains information about
> connections to the smtp server.)
There should be no difference, I don't know why you get no logs here.
HTH, Gerrit.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: qpsmtpd-forkserver on Mac OS X
2006-06-06 15:57 ` Gerrit Pape
@ 2006-06-07 3:36 ` Michael Glaesemann
2006-06-07 9:20 ` Laurent Bercot
0 siblings, 1 reply; 8+ messages in thread
From: Michael Glaesemann @ 2006-06-07 3:36 UTC (permalink / raw)
Cc: supervision
On Jun 7, 2006, at 0:57 , Gerrit Pape wrote:
> This may be another problem, independent from what you report: AFAIK
> the poll() implementation of Mac OSX 10.4/Intel is broken, and doesn't
> work for named pipes. runit (or better daemontools' iopause()) has an
> alternative implementation using select(), but this isn't chosen while
> building as poll() is available, but broken.
Interesting. Thanks, Gerrit. I didn't save the STDOUT of the
installation, so I can't easily verify whether it chose select() or
poll(). However, I can verify that I am able to use runit and launchd
on this machine to launch a simple Perl script that just logs to syslog.
http://www.nntp.perl.org/group/perl.qpsmtpd/5172
People on the qpstmpd mailing list have been giving me lots of
helpful suggestions, but no solution yet.
>> The qpsmtpd wiki gives instructions[2] on how to configure qpsmtpd-
>> forkserver with runit. Here's /var/service/qpsmtpd/run
>>
>> $ cat /var/service/qpsmtpd/run
>> #!/bin/bash
>> unset PERL_UNICODE
>> /usr/local/qpsmtpd/qpsmtpd-forkserver --detach --user www --port 25
>> $
>
> The service daemon must not background (or 'daemonize') when
> supervised
> by runit, but must run in the foreground. Try to remove the --detach
> option.
Right. This is the same advice I got from the qpsmtpd list. This has
now been fixed in the run script.
>> When org.smarden.runit.plist is loaded (either manually using
>> launchctl or automatically on server restart), qsmtpd-forkserver
>> doesn't appear to work. However, something is definitely running on
>> port 25:
>
> Maybe you didn't stop the daemon you started before from the command
> line, and which detached from the terminal and process tree, and now
> still listens on the port.
I rebooted the machine to make completely sure there wasn't anything
else listening on port 25. It looks like for some reason the qpsmptd-
forkserver server is quitting immediately after being started, and
runit then restarts it (as expected), only to have the qpsmtp daemon
quit again. The question now appears to be why the server is
quitting. The server runs correctly when launched by the run script
(sudo ./run without the runit service running), but not when
controlled by runit. :/
>> I don't see anything in /var/log/system.log (where launchd problems
>> are logged) or /var/log/mail.log (the qpsmtpd log). When using
>> launchd/runit, nothing is logged to /var/log/mail.log at all. (When
>> run from the command line, mail.log contains information about
>> connections to the smtp server.)
>
> There should be no difference, I don't know why you get no logs here.
The logging bit is still a bit of a mystery to me as well. Though if
the qpsmtp daemon is quitting immediately after starting, its not
going to be accepting connections/have anything to log anyway. That
would explain the empty logs.
Thanks for your analysis. It confirms things explained on the qpsmptd
list and is helping my understanding of both qpsmptd and runit.
Cheers,
Michael Glaesemann
grzm seespotcode net
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: qpsmtpd-forkserver on Mac OS X
2006-06-07 3:36 ` Michael Glaesemann
@ 2006-06-07 9:20 ` Laurent Bercot
2006-06-07 9:54 ` Michael Glaesemann
0 siblings, 1 reply; 8+ messages in thread
From: Laurent Bercot @ 2006-06-07 9:20 UTC (permalink / raw)
> The server runs correctly when launched by the run script
> (sudo ./run without the runit service running), but not when
> controlled by runit. :/
This is not the same.
When you do "sudo ./run", the run script is executed with most of
your user environment (open fds, environment variables and whatnot),
modified in some way by the sudo configuration.
When the run script is started by runit, it is run with a "boot"
environment: init spawns runsvdir, which spawns runsv, which spawns
your service.
There's something in your service that works in a user environment
and doesn't in a boot environment. I don't know qpsmtpd at all, but
here are some random points:
- Does your server work when stdin isn't a terminal? If not, why?
- (depending on your boot configuration) Does your server work when
stdin is closed?
- What do kernel limits look like in your boot environment? Are
there ulimit commands in log in scripts that make them less strict
in user environments?
HTH,
--
Laurent
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: qpsmtpd-forkserver on Mac OS X
2006-06-07 9:20 ` Laurent Bercot
@ 2006-06-07 9:54 ` Michael Glaesemann
2006-06-07 12:28 ` Charlie Brady
0 siblings, 1 reply; 8+ messages in thread
From: Michael Glaesemann @ 2006-06-07 9:54 UTC (permalink / raw)
Cc: supervision
On Jun 7, 2006, at 18:20 , Laurent Bercot wrote:
>> The server runs correctly when launched by the run script
>> (sudo ./run without the runit service running), but not when
>> controlled by runit. :/
>
> This is not the same.
Laurent,
Thank you *very* much for pointing out possible points of difference
between these two situations. I'll do my best to look into these areas.
> - Does your server work when stdin isn't a terminal? If not, why?
> - (depending on your boot configuration) Does your server work when
> stdin is closed?
I recognize you aren't familiar with qpsmptd, but would you have an
idea how I might test this? I'm really at the edge of what I know how
to do here.
Thank you for your detailed response!
Michael Glaesemann
grzm seespotcode net
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: qpsmtpd-forkserver on Mac OS X
2006-06-07 9:54 ` Michael Glaesemann
@ 2006-06-07 12:28 ` Charlie Brady
2006-06-07 13:40 ` Laurent Bercot
0 siblings, 1 reply; 8+ messages in thread
From: Charlie Brady @ 2006-06-07 12:28 UTC (permalink / raw)
Cc: supervision
On Wed, 7 Jun 2006, Michael Glaesemann wrote:
> I recognize you aren't familiar with qpsmptd, but would you have an idea how
> I might test this? I'm really at the edge of what I know how to do here.
env -i PATH=... ./run
[Check "man env" to see if syntax differs between linux and OS X.]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: qpsmtpd-forkserver on Mac OS X
2006-06-07 12:28 ` Charlie Brady
@ 2006-06-07 13:40 ` Laurent Bercot
2006-10-12 6:56 ` Michael Glaesemann
0 siblings, 1 reply; 8+ messages in thread
From: Laurent Bercot @ 2006-06-07 13:40 UTC (permalink / raw)
> env -i PATH=... ./run
Also, to run the service with stdin closed: ... ./run <&-
To run the service with stdin open, but no terminal: ... ./run </dev/null
Those are standard Unix shell features, MacOS X should support them.
Please share the results of your experiments. :)
--
Laurent
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: qpsmtpd-forkserver on Mac OS X
2006-06-07 13:40 ` Laurent Bercot
@ 2006-10-12 6:56 ` Michael Glaesemann
0 siblings, 0 replies; 8+ messages in thread
From: Michael Glaesemann @ 2006-10-12 6:56 UTC (permalink / raw)
Cc: supervision
On Jun 7, 2006, at 22:40 , Laurent Bercot wrote:
>> env -i PATH=... ./run
>
> Also, to run the service with stdin closed: ... ./run <&-
> To run the service with stdin open, but no terminal: ... ./run </
> dev/null
>
> Those are standard Unix shell features, MacOS X should support them.
> Please share the results of your experiments. :)
Just to belatedly and inconclusively close this thread, I was moved
onto other projects before being able to resolve this. I wasn't able
to find a solution and don't know when I'll be able to return to this
issue.
Thanks again for everyone's assistance! Sorry I wasn't able to find a
solution and post it.
Michael Glaesemann
grzm seespotcode net
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-10-12 6:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-05 8:58 qpsmtpd-forkserver on Mac OS X Michael Glaesemann
2006-06-06 15:57 ` Gerrit Pape
2006-06-07 3:36 ` Michael Glaesemann
2006-06-07 9:20 ` Laurent Bercot
2006-06-07 9:54 ` Michael Glaesemann
2006-06-07 12:28 ` Charlie Brady
2006-06-07 13:40 ` Laurent Bercot
2006-10-12 6:56 ` Michael Glaesemann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).