@@ -122,6 +122,10 @@ def _create_container(self, name, image, command, unit, **kwargs):
122122 l .update ({'cpu' : '-c {}' .format (cpu )})
123123 else :
124124 l .update ({'cpu' : '' })
125+ # should a special entrypoint be used
126+ entrypoint = kwargs .get ('entrypoint' )
127+ if entrypoint :
128+ l .update ({'entrypoint' : '{}' .format (entrypoint )})
125129 # construct unit from template
126130 for f in unit :
127131 f ['value' ] = f ['value' ].format (** l )
@@ -194,9 +198,10 @@ def _destroy_container(self, name):
194198 def _destroy_log (self , name ):
195199 return self ._delete_unit (name + '-log' )
196200
197- def run (self , name , image , command ): # noqa
201+ def run (self , name , image , entrypoint , command ): # noqa
198202 """Run a one-off command"""
199- self ._create_container (name , image , command , copy .deepcopy (RUN_TEMPLATE ))
203+ self ._create_container (name , image , command , copy .deepcopy (RUN_TEMPLATE ),
204+ entrypoint = entrypoint )
200205
201206 # wait for the container to get scheduled
202207 for _ in range (30 ):
@@ -316,6 +321,6 @@ def attach(self, name):
316321 {"section" : "Unit" , "name" : "Description" , "value" : "{name} admin command" },
317322 {"section" : "Service" , "name" : "ExecStartPre" , "value" : '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker pull $IMAGE"''' }, # noqa
318323 {"section" : "Service" , "name" : "ExecStartPre" , "value" : '''/bin/sh -c "docker inspect {name} >/dev/null 2>&1 && docker rm -f {name} || true"''' }, # noqa
319- {"section" : "Service" , "name" : "ExecStart" , "value" : '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker run --name {name} --entrypoint=/bin/bash -a stdout -a stderr $IMAGE -c ' {command}' "''' }, # noqa
324+ {"section" : "Service" , "name" : "ExecStart" , "value" : '''/bin/sh -c "IMAGE=$(etcdctl get /deis/registry/host 2>&1):$(etcdctl get /deis/registry/port 2>&1)/{image}; docker run --name {name} --entrypoint={entrypoint} -a stdout -a stderr $IMAGE {command}"''' }, # noqa
320325 {"section" : "Service" , "name" : "TimeoutStartSec" , "value" : "20m" },
321326]
0 commit comments