参考:
以stf-provider@.service单元文件为例
[Unit]Description=STF providerAfter=adbd.serviceBindsTo=adbd.service[Service]EnvironmentFile=/etc/environmentTimeoutStartSec=0Restart=alwaysExecStartPre=-/usr/bin/docker kill %p-%iExecStartPre=-/usr/bin/docker rm %p-%iExecStart=/usr/bin/docker run --rm \ --name %p-%i \ --net host \ openstf/stf:v2.3.1 \ stf provider \ --name "%H/%i" \ --connect-sub tcp://192.168.100.118:7250 \ --connect-push tcp://192.168.100.118:7270 \ --storage-url http://192.168.100.116/ \ --public-ip ${COREOS_PRIVATE_IPV4} \ --min-port=15000 \ --max-port=15500 \ --heartbeat-interval 10000 \ --screen-ws-url-pattern "ws://192.168.100.116/d/%i/<%= serial %>/<%= publicPort %>/"ExecStartPost=-/bin/sh /home/core/updateNginx.shExecStop=-/usr/bin/docker stop -t 10 %p-%i[X-Fleet]Conflicts=stf-provider@*.service
%p
非转义的前缀名(Unescaped prefix name)
其值就是stf-provider%i
实例名(Instance name)
这个值取决于启动此服务时指定的名称 如fleetctl start stf-provider@1则值为1%H
主机名(Hostname Allows you to run the same unit file across many machines. Useful for service discovery. Example: /domains/example.com/%H:8081)
coreos中取的是/etc/hostname文件中的值%n
Full unit name Useful if the name of your unit is unique enough to be used as an argument on a command.
%N
Unescaped full unit name
%m
机器ID(Machine ID Useful for namespacing etcd keys by machine. Example: /machines/%m/units)
coreos中取的是/etc/machine-id文件中的值%b
BootID Similar to the machine ID, but this value is random and changes on each boot