2017-02-04 13:42:41 -06:00
|
|
|
[Unit]
|
|
|
|
Description=DHCP relay container
|
2019-11-26 18:59:45 -06:00
|
|
|
Requires=updategraph.service
|
2019-10-31 11:18:26 -05:00
|
|
|
After=updategraph.service swss.service syncd.service teamd.service
|
2021-02-25 06:26:24 -06:00
|
|
|
BindsTo=sonic.target
|
|
|
|
After=sonic.target
|
2018-12-03 18:01:44 -06:00
|
|
|
Before=ntp-config.service
|
2019-11-05 20:32:14 -06:00
|
|
|
StartLimitIntervalSec=1200
|
|
|
|
StartLimitBurst=3
|
2017-02-04 13:42:41 -06:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
User={{ sonicadmin_user }}
|
[oneimage]: Fix race condition in systemd container services (#421)
When Type=simple, systemd will consider the service activated immediately
after specified in ExecStart process is started. If there is downstream
service depending on the state prepared in ExecStart, there will be race condition.
For example, issue #390. In this case, database.service calls database.sh, which
calls docker run or docker start -a to start database container. However, systemd
considers database.service successfully started at the time database.sh begins,
not after docker run finishes. As database.service is consider started, bgp.service
can be started. The redis database, which bgp service depends on, might or might not
have been started at this time point.
To fix this issue (and still keeping the functionality to monitor docker status with
systemd), we split the ExecStart process into an ExecStartPre part and an ExecStart
part. docker run is splitted into docker run -d then docker attach , while docker start
-a is splitted into docker start and then docker attach. In this way, we make sure
the downstream services are blocked until container is successfully started.
2017-03-22 15:04:48 -05:00
|
|
|
ExecStartPre=/usr/bin/{{ docker_container_name }}.sh start
|
2019-03-08 12:59:41 -06:00
|
|
|
ExecStart=/usr/bin/{{ docker_container_name }}.sh wait
|
2017-02-04 13:42:41 -06:00
|
|
|
ExecStop=/usr/bin/{{ docker_container_name }}.sh stop
|
2019-11-05 20:32:14 -06:00
|
|
|
RestartSec=30
|
2017-02-04 13:42:41 -06:00
|
|
|
|
|
|
|
[Install]
|
2021-02-25 06:26:24 -06:00
|
|
|
WantedBy=sonic.target
|