habitat-sh / habitat

Modern applications with built-in automation
https://www.habitat.sh
Apache License 2.0
2.6k stars 314 forks source link

Hab Supervisor: add a "run a task and then shut down" mode #4676

Open tashimi opened 6 years ago

tashimi commented 6 years ago

We should add the ability for the Habitat Supervisor to start up, run a job, and then exit and shut down.

This has come up in a couple different scenarios, including build jobs in a Jenkins/Concourse pipeline and running as a test scenario in a High Performance Computing (HPC) cluster with Singularity.

elliott-davis commented 6 years ago

Additionally, when the Supervisor shuts down, it should pass the exit code from its child as it's own exit code.

mwrock commented 6 years ago

Just to clarify, do we mean running a "supervisor service" that has an intentionally terminating run hook? Or would this specifically start its own supervisor to run a new "job" primitive?

christophermaier commented 6 years ago

@mwrock This would probably be a "run this package until it exits successfully, and then stop".

Right now, the Supervisor will continually restart a service if it exits successfully.

This also would mean that the things the Supervisor can run now are not necessarily "services" (i.e., long running daemon-like processes), but also "jobs".

mwrock commented 6 years ago

ok that makes sense. I love the idea. I have had a couple times where I thought a hab pkg exec could get a job done and then I remember "oh no handlebars or binds." Foe example a one off DB migration job.

dm4r commented 6 years ago

👍

bdangit commented 6 years ago

Perhaps there should be a flag that user can sethab start —run_once some/pkg? Or allow the the pkg owner to set a flag that tells the supervisor that the process is finished doing work.

christophermaier commented 6 years ago

@bdangit Agreed; we can probably take some inspiration from Erlang supervisor restart strategies:

restart defines when a terminated child process is to be restarted.

A permanent child process is always restarted.
A temporary child process is never restarted (not even when the supervisor restart strategy is rest_for_one or one_for_all and a sibling death causes the temporary process to be terminated).
A transient child process is restarted only if it terminates abnormally, that is, with an exit reason other than normal, shutdown, or {shutdown,Term}.

The restart key is optional. If it is not given, the default value permanent will be used.
baumanj commented 6 years ago

Confirmed valid in v0.57

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

stale[bot] commented 12 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.