systemd单元失败,错误"尾随垃圾"

时间:2015-05-26 10:33:47

标签: coreos systemd

我的systemd输出有以下非常奇怪的错误:

5月26日10:21:11 ip-10-30-2-251.ec2.internal systemd [1]:[/ run / fleet / units / someservice.service:13]跟踪垃圾,忽略。 5月26日10:21:11 ip-10-30-2-251.ec2.internal systemd [1]:[/ run / fleet / units / someservice.service:14]缺少' ='。

这是在我运行以下服务时引起的:

[Unit]
Description=SOMESERVICE
Requires=docker.service  
After=docker.service

[Service]
User=core
TimeoutSec=15m
RemainAfterExit=yes
EnvironmentFile=/etc/environment
ExecStartPre=/usr/bin/docker pull micronginx
ExecStartPre=/usr/bin/docker pull microphp
ExecStart=/usr/bin/bash -c ' \
    MACHINE=`cat /etc/machine-id`; \
    etcdctl get /service/someservice/machines/$MACHINE/version; \
    if [ $? -ne 0 ]; then \
        etcdctl set /service/someservice/machines/$MACHINE/version 0; \
    fi; \
    while true; \
    do \
        MACHINE_VERSION=$(etcdctl get /service/someservice/machines/$MACHINE/version); \
        SOMESERVICE_VERSION=$(etcdctl get /service/someservice/version); \
        if [ "$MACHINE_VERSION" != "$SOMESERVICE_VERSION" ]; then \
            echo "Versions are different so starting deployment of version $SOMESERVICE_VERSION \n"; \
            etcdctl get /service/someservice/config > /tmp/someservice-$SOMESERVICE_VERSION; \
            SOMESERVICE_BASE_PORT=5000; \
            PORT=`echo $SOMESERVICE_VERSION | cut -d\'.\' -f 2`; \
            SOMESERVICE_PORT=$((SOMESERVICE_BASE_PORT+PORT)); \
            /usr/bin/docker pull someservice:$SOMESERVICE_VERSION; \
            /usr/bin/docker create -v /var/www --name someservice_$SOMESERVICE_VERSION someservice:$SOMESERVICE_VERSION; \
            /usr/bin/docker run --rm --name microphp_someservice_$SOMESERVICE_VERSION --volumes-from someservice_$SOMESERVICE_VERSION --env-file /tmp/someservice-$SOMESERVICE_VERSION microphp & \
            /usr/bin/docker run -d --name micronginx_someservice_$SOMESERVICE_VERSION --volumes-from someservice_$SOMESERVICE_VERSION -p $SOMESERVICE_PORT:80 --link=microphp_someservice_$SOMESERVICE_VERSION:php-fpm micronginx; \
            if [ $? -eq 0 ]; then \
                echo "Setting machine version in etcd to $SOMESERVICE_VERSION"; \
                etcdctl set /service/someservice/machines/$MACHINE/version "$SOMESERVICE_VERSION"; \
                sleep 1; \
                echo "New machine version is visible in etcd as $(etcdctl get /service/someservice/machines/$MACHINE/version)"; \
            fi; \
            rm -f /tmp/someservice-$SOMESERVICE_VERSION; \
        fi; \
        echo "sleep for 10 seconds and recheck \n"; \
        sleep 10; \
    done; '

[X-Fleet]
Global=true

任何想法为什么或如何解决此错误或可能导致错误的原因?

-S

1 个答案:

答案 0 :(得分:1)

我想我听说某个地方有一条服务的最大行长。你有没有尝试将这个巨大的命令放入脚本并执行该脚本?如果这不起作用,您可以创建多个ExecPre语句并一次构造一个部分的脚本。然后您的Exec可以运行该脚本。如果您使用的是cloud-config,则可以使用'write_file'命令将脚本写入目标计算机。

github issue max length

2048是一条线的最大长度(反引号被消耗,你的命令是一条巨线)。