MailScanner and MySQL

James Gray james at grayonline.id.au
Tue Apr 25 13:18:19 IST 2006


On Tue, 25 Apr 2006 22:00, Martin wrote:
> Hi,
>
> This may be a little OT, but i noticed a problem today on my debian
> testbox. I'm running Mailscanner, Postfix, Mailwatch and MySQL.
>
> When i reboot, MailScanner starts before MySQL, which gives me the
> following error in the maillog:
>
> MailScanner[1658]: Unable to initialise database connection: Can't
> connect to local MySQL server through socket
> '/var/run/mysqld/mysqld.sock' (2)
>
> I have to restart mailscanner in order to get it to connect to MySQL. Is
> there a easy way to either change start order of the services or make a
> little script to check if mysql is running before starting mailscanner?

If your system uses SysV type startup (Linux, Solaris, most Unixes in fact) 
then simply change the number for the "S??mailscanner" script in 
the /etc/rc?.d directories to be higher than the number for the MySQL 
process.

For BSD type startup, I'll leave that to other more experienced (although 
I'm embarrassed to admit, I maintain a swath of fBSD MailScanner 
installations :P - just never had the need to poke around the startup 
process).

You could always add a "while...do...done" loop to poll port 3306 (mysql) on 
the local interface in the mailscanner startup script, and not continue 
until you get a valid response from MySQL.  For this sort of task, I 
generally employ "hping3" (http://wiki.hping.org/home) as you can test the 
raw TCP flags and make sure you're getting a "SYN+ACK" back from MySQL, not 
a "RST+ACK" or something else.

HTH,

James
-- 
Fertility is hereditary.  If your parents didn't have any children,
neither will you.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.mailscanner.info/pipermail/mailscanner/attachments/20060425/1acd883d/attachment.bin


More information about the MailScanner mailing list