Welcome! Log In Create A New Profile

Advanced

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin
November 22, 2017 12:44PM
Hello!

On Tue, Nov 21, 2017 at 10:46:58PM +0200, Gena Makhomed wrote:

> Здравствуйте, All!
>
> nginx установлен из официального репозитория nginx.org, CentOS 7.4
>
> В логах вот такое наблюдается при перезапуске nginx 1.13.6:
>
> systemd: Starting nginx - high performance web server...
> nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
> nginx: nginx: configuration file /etc/nginx/nginx.conf test is successful
> systemd: Failed to read PID from file /var/run/nginx.pid: Invalid argument
> systemd: Started nginx - high performance web server.
>
> И вот такое при запуске nginx 1.13.7:
>
> systemd: Starting nginx - high performance web server...
> systemd: PID file /var/run/nginx.pid not readable (yet?) after start.
> systemd: Started nginx - high performance web server.
>
> Как это можно победить, чтобы в логах такого не было?
>
> Рекомендуют вот такой workaround: https://stackoverflow.com/a/42084804
> И еще вот такое нашлось заодно: https://stackoverflow.com/a/42555993
>
> Но это наверное неправильно будет, добавлять sleep 0.1 в юнит-файл?
>
> Обе эти ошибки возникают в systemd функции service_load_pid_file()
> https://github.com/systemd/systemd/blob/master/src/core/service.c#L815
> Когда systemd не может прочитать pid-файл.
>
> Насколько я понял из комментариев в функции service_enter_start()
> https://github.com/systemd/systemd/blob/master/src/core/service.c#L1909
>
> /* For forking services we wait until the start
> * process exited. */
>
> И в функции service_sigchld_event():
> https://github.com/systemd/systemd/blob/master/src/core/service.c#L2959
>
> /* Forking services may occasionally move to a new PID.
> * As long as they update the PID file before exiting the old
> * PID, they're fine. */
>
> Systemd считает что сервис запустился
> после того как start process exited ?
>
> А у nginx получается так, что start process exited,
> а pid файл еще не создан и это создает проблемы systemd?
>
> Можно ли как-то исправить поведение nginx,
> чтобы systemd не флудил в логи сообщениями об ошибках?

С точки зрения абстрактного счастья для всех даром - наверное,
поведение systemd логично, и на момент выхода запущенного процесса
pid-файл должен уже существовать.

С точки зрения практики - паттерн "daemon(); write_pidfile();"
используется чуть менее, чем везде, вплоть до соответствующих
библиотечных функций. Так что инициатива выглядит, скажем так,
сомнительной.

Проще всего, IMHO, это было бы заткнуть на уровне systemd,
дожидаясь появления pid-файла при необходимости.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 21, 2017 03:48PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 22, 2017 12:44PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 23, 2017 08:52AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 23, 2017 10:40AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 23, 2017 11:30AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Igor Sysoev November 23, 2017 11:46AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 23, 2017 12:18PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 23, 2017 12:34PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 23, 2017 12:14PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 23, 2017 02:02PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 23, 2017 04:02PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 23, 2017 06:14PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 23, 2017 11:14PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Evgeniy Berdnikov November 24, 2017 03:08AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Vadim A. Misbakh-Soloviov November 24, 2017 04:18AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 24, 2017 08:00AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 24, 2017 06:32AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Vadim A. Misbakh-Soloviov November 24, 2017 06:38AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Konstantin Tokarev November 24, 2017 06:46AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Pavel V. November 24, 2017 07:00AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 24, 2017 08:36AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 24, 2017 09:50AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Vadim A. Misbakh-Soloviov November 24, 2017 10:14AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 24, 2017 02:46PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 25, 2017 09:24AM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Slawa Olhovchenkov November 25, 2017 09:38AM

Re:systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Konstantin Tokarev November 25, 2017 08:48PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

S.A.N November 23, 2017 12:30PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Gena Makhomed November 23, 2017 12:56PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Maxim Dounin November 23, 2017 12:58PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Илья Шипицин November 23, 2017 01:32PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Konstantin Pavlov November 23, 2017 03:08PM

Re: systemd: PID file /var/run/nginx.pid not readable (yet?) after start.

Evgeniy Berdnikov November 23, 2017 02:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 65
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready