Welcome! Log In Create A New Profile

Advanced

Re: Подмена бинарника в докере

April 26, 2016 02:40AM
Так а если решение в лоб - запускать nginx не напрямую, а сделать на bash init скрипт и уже из него запускать nginx? Тогда никаких проблем с перезапуском nginx и умиранием докера.

25.04.2016, 22:55, "Anton Bessonov" <exelib@gmail.com>:
> Так и есть, ppid становится 1:
>
> # ps axw -o pid,ppid,user,%cpu,vsz,wchan,command
>    PID PPID USER %CPU VSZ WCHAN COMMAND
>      1 0 root 0.2 20044 pipe_w /bin/bash -c $(exec
> /usr/sbin/nginx -g "daemon off;")
>      5 1 root 0.0 31684 sigsus nginx: master process
> /usr/sbin/nginx -g daemon off;
>      6 5 nginx 0.0 32068 - nginx: worker process
>      7 0 root 0.6 20224 wait bash
>     11 7 root 0.0 17500 - ps axw -o
> pid,ppid,user,%cpu,vsz,wchan,command
>
> # kill -USR2 5
> # ps axw -o pid,ppid,user,%cpu,vsz,wchan,command
>    PID PPID USER %CPU VSZ WCHAN COMMAND
>      1 0 root 0.0 20044 pipe_w /bin/bash -c $(exec
> /usr/sbin/nginx -g "daemon off;")
>      5 1 root 0.0 31684 sigsus nginx: master process
> /usr/sbin/nginx -g daemon off;
>      6 5 nginx 0.0 32068 - nginx: worker process
>      7 0 root 0.0 20224 wait bash
>     12 5 root 0.0 31688 sigsus nginx: master process
> /usr/sbin/nginx -g daemon off;
>     13 12 nginx 0.0 32068 - nginx: worker process
>     14 7 root 0.0 17500 - ps axw -o
> pid,ppid,user,%cpu,vsz,wchan,command
>
> # kill -WINCH 5
> # ps axw -o pid,ppid,user,%cpu,vsz,wchan,command
>    PID PPID USER %CPU VSZ WCHAN COMMAND
>      1 0 root 0.0 20044 pipe_w /bin/bash -c $(exec
> /usr/sbin/nginx -g "daemon off;")
>      5 1 root 0.0 31684 sigsus nginx: master process
> /usr/sbin/nginx -g daemon off;
>      6 5 nginx 0.0 32068 - nginx: worker process
>      7 0 root 0.0 20224 wait bash
>     12 5 root 0.0 31688 sigsus nginx: master process
> /usr/sbin/nginx -g daemon off;
>     13 12 nginx 0.0 32068 - nginx: worker process
>     15 7 root 0.0 17500 - ps axw -o
> pid,ppid,user,%cpu,vsz,wchan,command
>
> # kill -QUIT 5
> # ps axw -o pid,ppid,user,%cpu,vsz,wchan,command
>    PID PPID USER %CPU VSZ WCHAN COMMAND
>      1 0 root 0.0 20044 pipe_w /bin/bash -c $(exec
> /usr/sbin/nginx -g "daemon off;")
>      7 0 root 0.0 20224 wait bash
>     12 1 root 0.0 31688 sigsus nginx: master process
> /usr/sbin/nginx -g daemon off;
>     13 12 nginx 0.0 32068 - nginx: worker process
>     16 7 root 0.0 17500 - ps axw -o
> pid,ppid,user,%cpu,vsz,wchan,command
>
> On 25.04.2016 21:08, Igor Sysoev wrote:
>
>>  On 25 Apr 2016, at 20:33, Anton Bessonov <exelib@gmail.com> wrote:
>>
>>>  Здравстуйте,
>>>
>>>  на сколько я помню, то энджин не посзоляет обновлять конфигурацию, если менять параметры некоторых директив, таких как пути к кэшам. Актуально использую подмену бинарника - вроде помогает.
>>>
>>>  Сейчас эксперементирую с тем же самым, только в контейнере. По умолчанию энджин имеет PID 1, что убивает контейнер после kill -QUIT 1.
>>>
>>>  В docker-compose делаю следующее:
>>>
>>>  version: '2'
>>>  services:
>>>    nginxt:
>>>      image: nginx
>>>      ports:
>>>        - "6283:80"
>>>      command: /bin/bash -c '$$(exec /usr/sbin/nginx -g "daemon off;")'
>>>
>>>  Вроде работает:
>>>
>>>  # ps auxf
>>>  USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
>>>  root 7 0.1 0.3 20224 3208 ? Ss 17:07 0:00 bash
>>>  root 12 0.0 0.2 17496 2064 ? R+ 17:07 0:00 \_ ps auxf
>>>  root 1 0.0 0.2 20044 2704 ? Ss 17:06 0:00 /bin/bash -c $(exec /usr/sbin/nginx -g "daemon off;")
>>>  root 5 0.0 0.4 31684 4860 ? S 17:06 0:00 nginx: master process /usr/sbin/nginx -g daemon off;
>>>  nginx 6 0.0 0.2 32068 2860 ? S 17:06 0:00 \_ nginx: worker process
>>>
>>>  # kill -USR2 5
>>>  # ps auxf
>>>  USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
>>>  root 7 0.0 0.3 20224 3208 ? Ss 17:07 0:00 bash
>>>  root 15 0.0 0.2 17496 2048 ? R+ 17:08 0:00 \_ ps auxf
>>>  root 1 0.0 0.2 20044 2704 ? Ss 17:06 0:00 /bin/bash -c $(exec /usr/sbin/nginx -g "daemon off;")
>>>  root 5 0.0 0.4 31684 4860 ? S 17:06 0:00 nginx: master process /usr/sbin/nginx -g daemon off;
>>>  nginx 6 0.0 0.2 32068 2860 ? S 17:06 0:00 \_ nginx: worker process
>>>  root 13 0.0 0.4 31688 5080 ? S 17:08 0:00 \_ nginx: master process /usr/sbin/nginx -g daemon off;
>>>  nginx 14 0.0 0.2 32068 2880 ? S 17:08 0:00 \_ nginx: worker process
>>>
>>>  # kill -WINCH 5
>>>  # ps auxf
>>>  USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
>>>  root 7 0.0 0.3 20224 3208 ? Ss 17:07 0:00 bash
>>>  root 16 0.0 0.1 17496 1956 ? R+ 17:09 0:00 \_ ps auxf
>>>  root 1 0.0 0.2 20044 2704 ? Ss 17:06 0:00 /bin/bash -c $(exec /usr/sbin/nginx -g "daemon off;")
>>>  root 5 0.0 0.4 31684 4860 ? S 17:06 0:00 nginx: master process /usr/sbin/nginx -g daemon off;
>>>  nginx 6 0.0 0.2 32068 2860 ? S 17:06 0:00 \_ nginx: worker process
>>>  root 13 0.0 0.4 31688 5080 ? S 17:08 0:00 \_ nginx: master process /usr/sbin/nginx -g daemon off;
>>>  nginx 14 0.0 0.2 32068 2880 ? S 17:08 0:00 \_ nginx: worker process
>>>
>>>  # kill -QUIT 5
>>>  # ps auxf
>>>  USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
>>>  root 7 0.0 0.3 20224 3208 ? Ss 17:07 0:00 bash
>>>  root 17 0.0 0.2 17496 2064 ? R+ 17:09 0:00 \_ ps auxf
>>>  root 1 0.0 0.2 20044 2704 ? Ss 17:06 0:00 /bin/bash -c $(exec /usr/sbin/nginx -g "daemon off;")
>>>  root 13 0.0 0.4 31688 5080 ? S 17:08 0:00 nginx: master process /usr/sbin/nginx -g daemon off;
>>>  nginx 14 0.0 0.2 32068 2880 ? S 17:08 0:00 \_ nginx: worker process
>>>
>>>  Теперь вопросы.
>>>
>>>  А оно работает? То есть какие проблемы могут возникнуть из-за такого изврашённого способа? Или есть способ лучше? (Ну в голову пришло ещё просто стартовать новый контейнер, подменивать днс и выкидывать старый... но я в этом не сильно шарю - как там ttl и всё такое, если нужно срочно).
>>  А что показывает
>>  ps axw -o pid,ppid,user,%cpu,vsz,wchan,command
>>
>>  В апгрэйде самое главное, чтобы ppid у мастер-процеса был 1.
>>
>>>  И ещё вопрос: А после -WINCH воркеры не должны вымирать?
>>  Должны. Но при автоматическом апгрэйде достаточно USR2/QUIT.
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru


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

Подмена бинарника в докере

Anton Bessonov April 25, 2016 01:34PM

Re: Подмена бинарника в докере

Igor Sysoev April 25, 2016 03:10PM

Re: Подмена бинарника в докере

Anton Bessonov April 25, 2016 03:56PM

Re: Подмена бинарника в докере

kron April 26, 2016 02:40AM

Re: Подмена бинарника в докере

Anton Bessonov April 26, 2016 12:20PM

Re: Подмена бинарника в докере

Igor Sysoev April 26, 2016 02:44AM

Re: Подмена бинарника в докере

Anton Bessonov April 26, 2016 12:28PM

Re: Подмена бинарника в докере

Igor Sysoev April 26, 2016 04:20PM

Re: Подмена бинарника в докере

Anton Bessonov May 05, 2016 11:56AM

Re: Подмена бинарника в докере

Igor Sysoev May 05, 2016 12:46PM

Re: Подмена бинарника в докере

Konstantin Pavlov April 26, 2016 01:10PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 124
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready