bitnami / gonit

Drop-in replacement for monit written in Go, with Apache 2.0 license
https://bitnami.com
Apache License 2.0
77 stars 13 forks source link

gonit fails to start nginx #16

Closed clampz closed 4 years ago

clampz commented 4 years ago

gonit.log:

time="2019-06-30T23:59:39-07:00" level=info msg="Performing process check php-fpm"
time="2019-06-30T23:59:39-07:00" level=info msg="Performing process check mysql"
time="2019-06-30T23:59:39-07:00" level=info msg="Performing process check nginx"
time="2019-07-01T00:01:39-07:00" level=info msg="Performing checks"
time="2019-07-01T00:01:39-07:00" level=info msg="Performing process check php-fpm"
time="2019-07-01T00:01:39-07:00" level=info msg="Performing process check mysql"
time="2019-07-01T00:01:39-07:00" level=info msg="Performing process check nginx"
time="2019-07-01T00:01:39-07:00" level=info msg="Service nginx is not running. Starting..."
time="2019-07-01T00:03:09-07:00" level=warning msg="Timed out waiting for nginx to start (4 tries left)"
time="2019-07-01T00:03:39-07:00" level=info msg="Performing checks"
time="2019-07-01T00:03:39-07:00" level=info msg="Performing process check php-fpm"
time="2019-07-01T00:03:39-07:00" level=info msg="Performing process check mysql"
time="2019-07-01T00:03:39-07:00" level=info msg="Performing process check nginx"
time="2019-07-01T00:03:39-07:00" level=info msg="Service nginx is not running. Starting..."
time="2019-07-01T00:05:09-07:00" level=warning msg="Timed out waiting for nginx to start (3 tries left)"
time="2019-07-01T00:05:39-07:00" level=info msg="Performing checks"
time="2019-07-01T00:05:39-07:00" level=info msg="Performing process check php-fpm"
time="2019-07-01T00:05:39-07:00" level=info msg="Performing process check mysql"
time="2019-07-01T00:05:39-07:00" level=info msg="Performing process check nginx"
time="2019-07-01T00:05:39-07:00" level=info msg="Service nginx is not running. Starting..."
time="2019-07-01T00:07:09-07:00" level=warning msg="Timed out waiting for nginx to start (2 tries left)"
time="2019-07-01T00:07:39-07:00" level=info msg="Performing checks"
time="2019-07-01T00:07:39-07:00" level=info msg="Performing process check php-fpm"
time="2019-07-01T00:07:39-07:00" level=info msg="Performing process check mysql"
time="2019-07-01T00:07:39-07:00" level=info msg="Performing process check nginx"
time="2019-07-01T00:07:39-07:00" level=info msg="Service nginx is not running. Starting..."
time="2019-07-01T00:09:09-07:00" level=warning msg="Timed out waiting for nginx to start (1 tries left)"
time="2019-07-01T00:09:39-07:00" level=info msg="Performing checks"
time="2019-07-01T00:09:39-07:00" level=info msg="Performing process check php-fpm"
time="2019-07-01T00:09:39-07:00" level=info msg="Performing process check mysql"
time="2019-07-01T00:09:39-07:00" level=info msg="Performing process check nginx"
time="2019-07-01T00:09:39-07:00" level=info msg="Service nginx is not running. Starting..."
time="2019-07-01T00:11:09-07:00" level=warning msg="Timed out waiting for nginx to start (0 tries left)"

/opt/bitnami/config/monit/conf.d/nginx.conf:

check process nginx
  with pidfile "/opt/bitnami/nginx/logs/nginx.pid"
  start program = "/opt/bitnami/nginx/scripts/ctl.sh start" with timeout 90 seconds
  stop program = "/opt/bitnami/nginx/scripts/ctl.sh stop" with timeout 90 seconds

I can test these start/stop and they work. I traced the code in checks.go until I got to line 488 where it says:

c.StartProgram.Exec()

Searching for Exec lead me to line 336 where it says:

c.logger.Debug(exec.Command("/bin/bash", "-c", c.Cmd).Run())

What is c.Cmd? Does it get substituted without embedded quotes? this could cause an issue with starting:

$ /opt/bitnami/nginx/scripts/ctl.sh start # this works
$ /bin/bash -c /opt/bitnami/nginx/scripts/ctl.sh start # this doesn't

Thanks

juamedgod commented 4 years ago

Yes, the command does not include the quotes, but that is the intended behavior. exec.Command expects each provided argument to be a separated element so it properly understands c.Cmd (/opt/bitnami/nginx/scripts/ctl.sh start) without the quotes.

While gonit is waiting for nginx to start, could you check if the nginx process is running? Does the pid file exists and contain the proper PID? Do you see any error logged in the nginx log?

/opt/bitnami/nginx/logs/error.log

clampz commented 4 years ago

This is only happening at the end of the month and I didn't catch it this time. I'll check at the end of this month!

marcosbc commented 4 years ago

Closing due to inactivity