0

I have 3 docker containers whose unit files are as below. Autorestart works for 1st and 2nd in the dependency chain but doesnot work for last. I replaced docker containers with some test bash scripts with same relationships and autorestart seem to work fine. So it is issue with auto restart with docker container on the edge(edge case). The issue is important because we cannot automatically recover after last container crashes for some reason.

container1(nehm) -> container 2(neca) > container 3(proxy)

container1

[Unit]
Description=NEHM service for LosAngelesTESRP
Requires=cassandra.service rabbitmq.service consul.service vesta-neca-LosAngelesTESRP.service
BindsTo=cassandra.service rabbitmq.service consul.service vesta-neca-LosAngelesTESRP.service
After=network.target remote-fs.target nss-lookup.target docker.service cassandra.service rabbitmq.service consul.service

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/opt/vesta/bin/service-wrapper vesta-nehm-LosAngelesTESRP
Type=forking
KillMode=mixed
PIDFile=/var/run/vesta-nehm-LosAngelesTESRP.pid
ExecStartPre=/bin/sh /etc/vesta/network/LosAngelesTESRP start
ExecStop=/usr/bin/docker stop vesta-nehm-LosAngelesTESRP
ExecStopPost=/bin/sh /etc/vesta/network/LosAngelesTESRP stop
RestartSec=30
Restart=always
StartLimitInterval=600
StartLimitBurst=3

container2

[Unit]
Description=neca service for LosAngelesTESRP
Requires=vesta-proxy-LosAngelesTESRP.service
BindsTo=vesta-nehm-LosAngelesTESRP.service vesta-proxy-LosAngelesTESRP.service
PartOf=vesta-nehm-LosAngelesTESRP.service
After=network.target remote-fs.target nss-lookup.target docker.service vesta-nehm-LosAngelesTESRP.service

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/opt/vesta/bin/service-wrapper vesta-neca-LosAngelesTESRP
Type=forking
KillMode=mixed
PIDFile=/var/run/vesta-neca-LosAngelesTESRP.pid
ExecStop=/usr/bin/docker stop vesta-neca-LosAngelesTESRP
RestartSec=30
Restart=always
StartLimitInterval=600
StartLimitBurst=3

container3 which has issue

[Unit]
Description=Proxy service for LosAngelesTESRP
BindsTo=vesta-neca-LosAngelesTESRP.service
PartOf=vesta-neca-LosAngelesTESRP.service
After=network.target network-interface-LosAngelesTESRP.service remote-fs.target nss-lookup.target docker.service vesta-neca-LosAngelesTESRP.service

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/opt/vesta/bin/service-wrapper vesta-proxy-LosAngelesTESRP
Type=forking
KillMode=mixed
PIDFile=/var/run/vesta-proxy-LosAngelesTESRP.pid
ExecStop=/usr/bin/docker stop vesta-proxy-LosAngelesTESRP
RestartSec=30

Restart=always
StartLimitInterval=600
StartLimitBurst=3

[root@services-2 system]# systemctl status vesta-proxy-LosAngelesTESRP.service
● vesta-proxy-LosAngelesTESRP.service - Proxy service for LosAngelesTESRP
   Loaded: loaded (/etc/systemd/system/vesta-proxy-LosAngelesTESRP.service; disabled; vendor preset: disabled)
   Active: inactive (dead) since Wed 2018-12-19 10:05:48 PST; 1h 19min ago
  Process: 2763 ExecStop=/usr/bin/docker stop vesta-proxy-LosAngelesTESRP (code=exited, status=0/SUCCESS)
  Process: 2533 ExecStart=/opt/vesta/bin/service-wrapper vesta-proxy-LosAngelesTESRP (code=exited, status=0/SUCCESS)
 Main PID: 2559

Dec 19 10:05:47 services-2.amber.lab systemd[1]: Installed new job vesta-proxy-LosAngelesTESRP.service/stop as 18224
Dec 19 10:05:47 services-2.amber.lab systemd[2763]: Executing: /usr/bin/docker stop vesta-proxy-LosAngelesTESRP
Dec 19 10:05:48 services-2.amber.lab docker[2763]: vesta-proxy-LosAngelesTESRP
Dec 19 10:05:48 services-2.amber.lab systemd[1]: Child 2763 belongs to vesta-proxy-LosAngelesTESRP.service
Dec 19 10:05:48 services-2.amber.lab systemd[1]: vesta-proxy-LosAngelesTESRP.service: control process exited, code=exited status=0
Dec 19 10:05:48 services-2.amber.lab systemd[1]: vesta-proxy-LosAngelesTESRP.service got final SIGCHLD for state stop
Dec 19 10:05:48 services-2.amber.lab systemd[1]: vesta-proxy-LosAngelesTESRP.service changed stop -> dead
Dec 19 10:05:48 services-2.amber.lab systemd[1]: Job vesta-proxy-LosAngelesTESRP.service/stop finished, result=done
Dec 19 10:05:48 services-2.amber.lab systemd[1]: Stopped Proxy service for LosAngelesTESRP.
Dec 19 10:05:48 services-2.amber.lab systemd[1]: vesta-proxy-LosAngelesTESRP.service: cgroup is empty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.