s6 覆盖 s6-svc 主管不听

s6 overlay s6-svc supervisor not listening

root@0cd6bfb7e363 app]# s6-svc /etc/services.d/uwsgi/
s6-svc: fatal: unable to control /etc/services.d/uwsgi/: supervisor not listening

[root@0cd6bfb7e363 app]# s6-svc -r /etc/services.d/uwsgi/
s6-svc: fatal: unable to control /etc/services.d/uwsgi/: supervisor not listening

然而

[root@0cd6bfb7e363 app]# ps aufx
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0    204     4 pts/0    Ss   01:42   0:00 s6-svscan -t0 /var/run/s6/services
root          30  0.0  0.0    188     8 pts/0    S    01:42   0:00 foreground  if   /etc/s6/init/init-stage2-redirfd   foreground    if     if      s6-echo      -n      --
root          40  0.0  0.0    184     4 pts/0    S    01:42   0:00  \_ foreground  s6-setsid  -gq  --  with-contenv  backtick  -D  0  -n  S6_LOGGING   printcontenv   S6_LO
root         261  0.0  0.0  15540  3864 pts/0    S    01:42   0:00      \_ /bin/bash
root         516  0.0  0.0  55204  3932 pts/0    R+   01:52   0:00          \_ ps aufx
root          31  0.0  0.0    204     4 pts/0    S    01:42   0:00 s6-supervise s6-fdholderd
root         241  0.0  0.0    204     4 pts/0    S    01:42   0:00 s6-supervise nginx
root         246  0.0  0.0  56840  7228 ?        Ss   01:42   0:00  \_ nginx: master process /usr/sbin/nginx
nginx        267  0.0  0.0  57484  5048 ?        S    01:42   0:00      \_ nginx: worker process
root         243  0.0  0.0    204     4 pts/0    S    01:42   0:00 s6-supervise uwsgi
root         245  0.0  0.0  15140  3012 ?        Ss   01:42   0:00  \_ bash ./run
root         255  0.2  0.0 259944 82060 ?        S    01:42   0:01      \_ uwsgi /etc/uwsgi.ini
root         339  0.0  0.0 259944 70452 ?        S    01:43   0:00          \_ uwsgi /etc/uwsgi.ini
root         340  0.0  0.0 259944 70452 ?        S    01:43   0:00          \_ uwsgi /etc/uwsgi.ini
root         341  0.1  0.0 297500 96408 ?        S    01:43   0:01          \_ uwsgi /etc/uwsgi.ini
root         342  0.0  0.0 259944 70452 ?        S    01:43   0:00          \_ uwsgi /etc/uwsgi.ini

有什么问题吗?

因为 s6-overlay 将服务复制到不同的文件夹。查看 ps 转储中的第一行:

[root@0cd6bfb7e363 app]# ps aufx
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0    204     4 pts/0    Ss   01:42   0:00 s6-svscan -t0 /var/run/s6/services

s6-supervisor正在监听/var/run/s6/services下的服务,所以你应该做的是:

$ s6-svc -u /var/run/s6/services/uwsgi

README文件中也有说明:

Stage 2.iii) Copy user services (/etc/services.d) to the folder where s6 is running its supervision and signal it so that it can properly start supervising them.

You may want to use a Read-Only Root Filesystem, since that ensures s6-overlay copies files into the /var/run/s6 directory rather than use symlinks.