我正在使用 CoreOS 来安排带有车队的 systemd 单元。我有两个单位(firehose.service
和firehose-announce.service
。我试图让firehose-announce.service
开始和停止firehose.service
。这是单位文件firehose-announce.service
:
[Unit]
Description=Firehose etcd announcer
BindsTo=firehose@%i.service
After=firehose@%i.service
Requires=firehose@%i.service
[Service]
EnvironmentFile=/etc/environment
TimeoutStartSec=30s
ExecStartPre=/bin/sh -c 'sleep 1'
ExecStart=/bin/sh -c "port=$(docker inspect -f '{{range $i, $e := .NetworkSettings.Ports }}{{$p := index $e 0}}{{$p.HostPort}}{{end}}' firehose-%i); echo -n \"Adding socket $COREOS_PRIVATE_IPV4:$port/tcp to /firehose/upstream/firehose-%i\"; while netstat -lnt | grep :$port >/dev/null; do etcdctl set /firehose/upstream/firehose-%i $COREOS_PRIVATE_IPV4:$port --ttl 300 >/dev/null; sleep 200; done"
RestartSec=30s
Restart=on-failure
[X-Fleet]
X-ConditionMachineOf=firehose@%i.service
我正在尝试使用BindsTo
start 和 stop offirehose.service
也将 start 或 stop的概念firehose-announce.service
。但这永远不会正确发生。如果firehose.service
停止,则firehose-announce.service
进入失败状态。但是当我开始时firehose.service
,firehose-announce.service
它不会启动。
我在这里做错了什么?