Solved my monit initialization delay caused by a non-responsive SMTP mail server.
Commenting out these two lines in /etc/monit/monitrc were the isloated config change I applied to make my monit restarts really fast!
# set mailserver smtp.sendgrid.com
# username "apikey" password "SG.."
These /var/log/monit.log entries helped:
[EDT Jun 9 06:28:32] error : Cannot create socket
to [smtp.sendgrid.com]:25 -- Connection timed out
[EDT Jun 9 06:28:32] error : Cannot open a connection to the mailserver 'smtp.sendgrid.com:25' -- Operation now in progress
[EDT Jun 9 06:28:32] error : Mail: No mail servers are available
monit -V
This is Monit version 5.16
Built with ssl, with pam and with large files
Copyright (C) 2001-2016 Tildeslash Ltd. All Rights Reserved.
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
uname -a
Linux prime3prod 4.4.0-1084-aws #94-Ubuntu SMP Fri May 17 13:10:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
This line reads
set daemon 10 with start delay 20
in my monitrc. But sometimes it stucks with 'initializing' for more than a minute. – mikezter – 2010-12-08T13:41:17.193Does the service take that long to create a .pid file? IIRC Monit needs that to verify the service is running. – LawrenceC – 2010-12-08T21:18:29.173
Actually your answer pointed me into the right direction: The init script i used started monit with the command line parameter
-d
which overrides directives in the config file. – mikezter – 2010-12-10T13:51:53.707