Назад | Перейти на главную страницу

Почему пропадает /run/nginx.pid? просто пропадает из системы каждый день?

ВАЖНАЯ ЗАМЕТКА: Мне больше не нужно перезапускать серверы (мои 3 VPS!), Чтобы файл pid вернулся в каталог /run/nginx.pid

Я просто набрал команду: sudo fuser -k 443 / tcp && запуск службы nginx

решает проблему на 24 часа, так как pid возвращается в / run / nginx / без перезапуска службы и всегда работает безотказно, но каждый день PID исчезает! даже если процесс nginx продолжается, а сервер всегда работает!

поэтому я могу использовать службу nginx start и pid возвращается, чтобы появиться, monit возвращает монитор процесса nginx, и я вернулся, чтобы контролировать команды: статус службы nginx, остановка службы nginx и т. д.

Внимание, я не говорю, что nginx перестает работать, сайты продолжают oline, я говорю, что файл: /run/nginx.pid исчезает каждый день, поэтому я больше не могу использовать команды, связанные с nginx, даже я ввожу команду

Судо fuser -k 443 / tcp

отсутствие файла /run/nginx.pid приносит несколько проблем, худшая из них - я не могу использовать команды, статус службы nginx, запуск, остановку и т. д.

========================= Мне нужен pid nginx для работы с monit, pid просто неожиданно исчезает, мне нужно перезапустить vps, чтобы верни его! это происходит каждую ночь! но даже если он исчезнет, ​​он все равно бежит! онлайн-сайт! но, очевидно, я не могу отслеживать статус, перезапускать, останавливать ... и т. д. Мне нужен pid! когда я пытаюсь увидеть статус через терминал, у меня

Вывод ошибки в командной строке терминала:

service nginx status
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
   Active: failed (Result: exit-code) since Sun 2017-11-05 06:25:07 WET; 1h 50mi
  Process: 5062 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 -
  Process: 1527 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code
  Process: 1522 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process 
 Main PID: 1486 (code=exited, status=0/SUCCESS)

Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 fail
Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:80 faile
Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 fail
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:80 faile
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 fail
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] still could not bind()
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Control process exited, code=exi
Nov 05 06:25:07 vps1 systemd[1]: Failed to start A high performance web server a
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Unit entered failed state.
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Failed with result 'exit-code'.
lines 1-18/18 (END)...skipping...
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
   Active: failed (Result: exit-code) since Sun 2017-11-05 06:25:07 WET; 1h 50mi
  Process: 5062 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 -
  Process: 1527 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code
  Process: 1522 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process 
 Main PID: 1486 (code=exited, status=0/SUCCESS)

Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 fail
Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:80 faile
Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 fail
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:80 faile
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 fail
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] still could not bind()
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Control process exited, code=exi
Nov 05 06:25:07 vps1 systemd[1]: Failed to start A high performance web server a
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Unit entered failed state.
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Failed with result 'exit-code'.
~
~
~
~
~
~
lines 1-18/18 (END)...skipping...
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2017-11-05 06:25:07 WET; 1h 50min ago
  Process: 5062 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=1/FAILURE)
  Process: 1527 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 1522 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 1486 (code=exited, status=0/SUCCESS)

Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 failed (98: Address already in use)
Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:80 failed (98: Address already in use)
Nov 05 06:25:06 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 failed (98: Address already in use)
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:80 failed (98: Address already in use)
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] bind() to 141.14.14.41:443 failed (98: Address already in use)
Nov 05 06:25:07 vps1 nginx[1527]: nginx: [emerg] still could not bind()
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Control process exited, code=exited status=1
Nov 05 06:25:07 vps1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Unit entered failed state.
Nov 05 06:25:07 vps1 systemd[1]: nginx.service: Failed with result 'exit-code'.

мой /etc/nginx/nginx.conf:

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 1024;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
    server_names_hash_bucket_size 128;
client_max_body_size 100M;
client_body_buffer_size 16k;

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 180;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
}


#mail {
#   # See sample authentication script at:
#   # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#   # auth_http localhost/auth.php;
#   # pop3_capabilities "TOP" "USER";
#   # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#   server {
#       listen     localhost:110;
#       protocol   pop3;
#       proxy      on;
#   }
# 
#   server {
#       listen     localhost:143;
#       protocol   imap;
#       proxy      on;
#   }
#}

Журнал Nginx:

2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:25:08 [emerg] 1703#1703: still could not bind()
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:27:39 [emerg] 1978#1978: still could not bind()
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:30:10 [emerg] 2076#2076: still could not bind()
2017/11/05 06:32:41 [emerg] 2208#2208: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:32:41 [emerg] 2208#2208: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:32:41 [emerg] 2208#2208: bind() to 141.14.14.41:80 failed (98: Address already in use)
2017/11/05 06:32:41 [emerg] 2208#2208: bind() to 141.14.14.41:443 failed (98: Address already in use)
2017/11/05 06:32:41 [emerg] 2208#2208: bind() to 141.14.14.41:80 failed (98: Address already in use)

Ubuntu 16.04-64b / nginx 1.10.3 /php7.0-fpm

Я пытаюсь просто увидеть статус: статус службы nginx:

nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2017-11-05 09:00:51 WET; 3h 5min ago
  Process: 5062 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=1/FAILURE)
  Process: 8636 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 8633 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 1486 (code=exited, status=0/SUCCESS)

Nov 05 09:00:50 vps1 nginx[8636]: nginx: [emerg] bind() to 141.14.14.41:443 failed (98: Address already in use)
Nov 05 09:00:50 vps1 nginx[8636]: nginx: [emerg] bind() to 141.14.14.41:80 failed (98: Address already in use)
Nov 05 09:00:50 vps1 nginx[8636]: nginx: [emerg] bind() to 141.14.14.41:443 failed (98: Address already in use)
Nov 05 09:00:51 vps1 nginx[8636]: nginx: [emerg] bind() to 141.14.14.41:80 failed (98: Address already in use)
Nov 05 09:00:51 vps1 nginx[8636]: nginx: [emerg] bind() to 141.14.14.41:443 failed (98: Address already in use)
Nov 05 09:00:51 vps1 nginx[8636]: nginx: [emerg] still could not bind()
Nov 05 09:00:51 vps1 systemd[1]: nginx.service: Control process exited, code=exited status=1
Nov 05 09:00:51 vps1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Nov 05 09:00:51 vps1 systemd[1]: nginx.service: Unit entered failed state.
Nov 05 09:00:51 vps1 systemd[1]: nginx.service: Failed with result 'exit-code'.

Если я перезапущу машину, перезагрузите ее сейчас (я просто делаю это снова), снова появится pid nginx (/run/nginx.pid), и monit вернется для наблюдения за процессом:

https://imgur.com/a/IWfch

но, конечно, никому не придется перезапускать vps только для того, чтобы выполнить статус nginx или перезапустить nginx, потому что на сервере Linux больше нет pid nginx!

Я действительно ценю твою помощь.

Первая попытка: pkill nginx && service nginx restart

Если файл все еще удаляется, вы можете использовать ftrace чтобы узнать, какой процесс удаляет ваш файл:

trace-cmd record -e \*unlink\*

Подождите, пока файл будет удален, нажмите CTRL + C, чтобы остановить запись trace-cmd ..., затем запустите:

trace-cmd report

Смотрите также: https://serverfault.com/a/310477/30946

Также убедитесь, что pid в /usr/lib/systemd/system/nginx.service или /etc/systemd/system/nginx.service files указывает на тот же файл, что и в /etc/nginx/nginx.conf