6

I have a service with this for a sidekick unit and keep receiving the error: [/run/fleet/units/tomcat-discovery@1.service:11] Trailing garbage, ignoring. tomcat-discovery@1.service has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.

I have seemingly tried every different combination I can think of and have successfully tested the command from the terminal without issue. If I remove the first call to etcdctl the second set command also works in the service file without issue. Any ideas as to where I am going wrong here?

[Unit]
Description=Tomcat web server etcd registration

# Requirements
Requires=etcd.service
Requires=tomcat@%i.service

# Dependency ordering and binding
After=etcd.service
After=tomcat@%i.service
BindsTo=tomcat@%i.service

[Service]

# Get CoreOS environmental variables
EnvironmentFile=/etc/environment

# Start

ExecStart=/bin/bash -c "\
while true; do \
    etcdctl set /services/tomcat/tomcat-%i/ip ${COREOS_PRIVATE_IPV4}:$(docker inspect --format='{{(index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort}}' tomcat.%i) --ttl 180; \
    etcdctl set /services/bind/tomcat-%i ${COREOS_PRIVATE_IPV4} --ttl 180; \
  sleep 60; \
done"

# Stop
ExecStop=/usr/bin/etcdctl rm --recursive /services/tomcat/tomcat-%i

[X-Fleet]
# Schedule on the same machine as the associated Apache service
MachineOf=tomcat@%i.service
3

I was able to correct the error by using single quotes around the /bin/bash -c command, using double quotes around the --format and double escape the port number. The final full ExecStart command is:

ExecStart=/bin/bash -c '\
while true; do \
  etcdctl set /services/tomcat/tomcat-%i/ip ${COREOS_PRIVATE_IPV4}:$(docker inspect --format="{{(index (index .NetworkSettings.Ports \\"8080/tcp\\") 0).HostPort}}" tomcat.%i) --ttl 180; \
  etcdctl set /services/bind/tomcat-%i ${COREOS_PRIVATE_IPV4} --ttl 180; \
sleep 60; \
done'

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.