orchardup/fig — pull request #74 by shavrin-ivan (2014-02-01 19:28:18+00:00)
Title: onStart, onStop events for containers

I use fig for running local development environment (django projects). All works fine, but after each restarting of services I need manually reconfigure hipache (because ip address of www container changed). I try to add some functionality (it's dirty, untested, just idea implementations) for run some commands on start/stop of services.

For example (fig.yml):

```yaml
www:
build: .
command: python manage.py runserver 0.0.0.0:8000
events:
onStart:
- redis-cli del frontend:project.dev
- redis-cli rpush frontend:project.dev project
- redis-cli rpush frontend:project.dev http://%(.NetworkSettings.IPAddress)s:8000
onStop:
- redis-cli del frontend:project.dev
```

This options should be configure hipache on ```fig up``` with ```www``` container ip address. Commands executed on host machine. Commands executed in order (as in options). Commands can use container options (for example ```.NetworkSettings.IPAddress```) as in ```docker inspect``. It's work good for me. But there is a question, do *fig* need this option, or not. I saw those problems:

* Broke *fig run* functionality, for example if I want to start django shell I can't start it with command ```fig run www python manage.py shell```, because onStart event will be executed (that broke http access to project via hipache). So I must create copy of www services (called shell) and run commands with those service.
* Broke *fig scale* functionality. I didn't use it, but someone do. Those events binding on containers, for supporting scale functionality they are must bind to service.

Any thoughts, need or not *events* option?