signalfx / maestro-ng

Orchestration of Docker-based, multi-host environments
https://signalfx.com
Apache License 2.0
685 stars 83 forks source link

Added rexec to allow execute script inside of container. #169

Closed zsuzhengdu closed 8 years ago

zsuzhengdu commented 8 years ago

Besides allowing operator to execute script on the path where maestro-ng runs, it would be nice to add the feature that allows operator to execute the script inside of running container.

Therefore, a check script could be added to check the status of 'required' service before starting. For example, check whether 'zookeeper' is fully stated before starting kafka.

  kafka:
    image: docker.cenx.localnet:5000/kafka:latest
    requires: [ zookeeper ]
    lifecycle:
      running: [{type: rexec, command: "python check.py"}]
    instances:
      kafka1:
        ship: machine
        ports: {client: 4082}
        lifecycle:
          running: [{type: tcp, port: client}]

NOTE: 'check.py' exists inside 'kafka' container.

mpetazzoni commented 8 years ago

Please also provide documentation for this new lifecycle helper in docs/lifecycle_helpers.rst.

mpetazzoni commented 8 years ago

@zsuzhengdu ping?

mpetazzoni commented 8 years ago

Nice, this is cleaner. But it doesn't look like it's waiting for the script to finish executing. If it's still running, it will just return false and another process will be started the following second.

mpetazzoni commented 8 years ago

Awesome. I'm assuming you're tested this? Do you mind squashing your changes into a single commit so I can merge a clean commit?

Thanks!

zsuzhengdu commented 8 years ago

I have tested this feature as far as I could.

One clean commit has been pushed as per request.

Thank you for your help for reviewing this PR!

mpetazzoni commented 8 years ago

Awesome; thanks!