rejeep / prodigy.el

Manage external services from within Emacs
GNU General Public License v3.0
544 stars 39 forks source link

Dependencies #14

Open rejeep opened 10 years ago

rejeep commented 10 years ago

Some of my services require other services in order to fully work. I suggest adding the property :depends-on. For example:

(prodigy-define-service
  :name "Script"
  :cwd "~/Code/script"
  :command "nodemon"
  :args '("app.coffee")
  :tags '(work))

(prodigy-define-service
  :name "Playground"
  :cwd "~/Code/playground"
  :command "nodemon"
  :args '("app.coffee")
  :tags '(work)
  :port 7171
  :depends-on '("Script"))

Starting service "Playground" would also start service "Script". It should not stop or restart dependencies since other services might rely on it.

shosti commented 10 years ago

Why not just use :name instead of a new :id attribute?

rejeep commented 10 years ago

Well, the reason I had in mind was that name is something that might change from time to time, while an id would not. I want to be able to change the name without updating a lot of other services. Just an idea. That's why I created this issue to create some discussion. :)

magnars commented 10 years ago

I have a feeling you'll get a lot of services with equal :name and :id. And if the name changes, wouldn't the id likely be outdated too?

rejeep commented 10 years ago

You guys are probably right, updating the issue.

rejeep commented 10 years ago

Id's are however better for people naming their services like this. But that's not something I recommend :)

shosti commented 10 years ago

Would it be useful to have the ability for one process to wait until another is in a ready state?

rejeep commented 10 years ago

Good thinking. For example, Rails won't start without a database. Would make things a bit more complex though.

FrancisMurillo commented 7 years ago

For me, I wanted to treat several services as one master service or set. Starting and stopping together instead of doing it individually. Not dependencies per se but a guarantee that several services work together instead.

I made an external module prodigy-set.el to do so. I thought about hacking with prodigy to get it done but there are concerns that might leak such as extra libraries (probably deferred.el but abstaining), overlapping or circular sets, action locking and others so I thought an external mode might offer better safety.

My use case is with using a tor proxy with w3m. In order to join them, it needs a middleman proxy such as polipo and privoxy or both. I setup each proxy as a service but I want them to start in order when each is ready; likewise when one is down, I want them all down. The screencast shows my intention.

I do hope there is an official dependency management working to make things easier.

rejeep commented 7 years ago

The downside with groups is that some service might have to be started for another to be able to start. I think the elegancy with dependencies is that both issues are solved with it.

leemeichin commented 8 months ago

I've been looking at this and it seems like the current tags feature is close to it but doesn't quite do the thing we want. :needs '(x y z) would be enough to say 'ensure all of these are started before starting the current one'.

It's what docker-compose and CI pipelines do without overthinking it.