Open Equanox opened 2 years ago
A usecase for a post script could be to clean up some files that could have been generated during the run time of an interactive task, e.g. logfiles.
I agree for our current use case init is the behavior we want and it makes sense to ommit Pre/Post for now .
Executing Init This seems to be a good place https://github.com/benchkram/bob/blob/main/pkg/ctl/commander.go#L16 to trigger the init script run. binary&compose start procedure is over at this point in time. Control is given to the TUI to assure output is correctly streamed to the user.
Working together with the TUI
From a implementation standpoint it seems to be required that init must fullfill the Control interface
https://github.com/benchkram/bob/blob/main/pkg/ctl/commander.go#L164 to receive the stop/cancel cmd from the TUI correctly. Though it requires us to reuse the shell from the build tasks... the implementation could be relatively easy as restart is not required and the shell can handle a canceable context, see https://github.com/benchkram/bob/blob/main/bobtask/run.go
Run task A run-task with init looks like this?
run:
server:
type: binary
path: ./build/server
init: |-
./run-database-init.sh
In the case of init:
being used on multiple levels in a pipeline the init cmd's should only be executed when the umbrella task triggers. Could make signal handling much easier.
Out of scope:
We made the experience that often script can only be executed after preconditions are fulfilled like a /health
route returning 200. Same for database ram pup as it takes a while till a database is functional when started detached. Tough i would leave those kind of preconditions checks to the script called with init.
Pre scripts closed by #84
Run Workflow
Assumption
Pre can be handled by dependencies. --> No need for further implementation.
Post is meant to be done after a Task has finished. Since our run tasks are meant to stay alive it doesn't make sense to do anything after stopping this task.
Init is meant to run as soon as the run task is in a running state (e.g. docker-compose up has all containers in running|healthy state). This is what is meant to be implemented with this ticket.
Leads to following run workflow: