Foreman: Concept: dependency

Created on 17 Jan 2012  ·  3Comments  ·  Source: ddollar/foreman

Hello,

I've created a fork to test a concept. We're using Foreman primarily in development to run Redis, a Resque worker and a Resque scheduler. These worker and scheduler depend on Redis to be started and in some cases fail because of that.

The version at https://github.com/rvanlieshout/foreman supports the defenition of dependency in the Procfile. For now it only uses a delay of 5 seconds to allow a parent to get started. A procfile could look like:

mongodb:       mongod --quiet --dbpath=db/mongo/
| redis:       redis-server /opt/local/etc/redis.conf
| | worker:    bundle exec rake environment resque:work QUEUE=* VERBOSE=1 RAILS_ENV=development
| | scheduler: bundle exec rake resque:scheduler QUEUE=* VERBOSE=1 RAILS_ENV=development
post_office:   post_office --smtp 10025 --pop3 10110

(Note: Redis does not depend on Mongo here... just to demonstrate)

When a "foreman start" is executed it starts Mongo and PostOffice first, followed by Redis after 5 seconds and the worker and scheduler after 10.

This version of Foreman is backwards compatible, but raises some other issues / questions:

  • Why wait 5 seconds? Are we able to deterine when a process is 'ready' for the dependencies to be started
  • Don't wait 5 seconds when stopping processes when we could just wait for the parent to stop
  • Which effect does this dependency has when exporting?

So... Have you had questions related to dependency before? Do you think this solution might be something that is to be included in a future version of Foreman?

And... thanks for this project! It really helps us improving our development workflow.

All 3 comments

There isn't really any way to tell when something is "ready" other than detecting if it has bound to its assigned port. Not all processes bind to a port, and I'd rather not introduce this rather complex relationship into foreman.

If you were feeling so inclined you could have your processes wrapped with a script that watched for something else to become available before starting the intended process.

Cheers,
David

I would love this :( - I have a bunch of RTSPProxy and RTSPClient processes and I want to delay starting the clients.

Is it implemented yet?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wireframe picture wireframe  ·  23Comments

millisami picture millisami  ·  3Comments

dunkstewart picture dunkstewart  ·  12Comments

davidalejandroaguilar picture davidalejandroaguilar  ·  6Comments

maxehmookau picture maxehmookau  ·  5Comments