Where would you put setup teardown code?

39 views
Skip to first unread message

Andy Chambers

unread,
Oct 11, 2015, 6:52:01 PM10/11/15
to Onyx
Hi All,

If you wanted some code to run before *any* tasks were processed (e.g. ensure database tables/indices are in place), is there anything in the "job" to configure or would you just run this code yourself before submitting the job?

Cheers,
Andy

Mike Drogalis

unread,
Oct 11, 2015, 7:13:55 PM10/11/15
to Andy Chambers, Onyx
You're on your own with infrastructure set up.

--
You received this message because you are subscribed to the Google Groups "Onyx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to onyx-user+...@googlegroups.com.
To post to this group, send email to onyx...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/onyx-user/f8ac0f3b-e8d7-4458-adcf-72caba6862a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lucas Bradstreet

unread,
Oct 12, 2015, 7:24:49 AM10/12/15
to Andy Chambers, Onyx
Hi Andy,

At this stage the place where I'd put it would be before any code that makes the submit-job call. If you need to pass in information about the tables you setup in this call, you can then pass it in to the job data when you call submit-job.

A reasonably hacky alternative would be to make it in a before-task-start lifecycle on a task, however you must ensure that the setup will not take place more than once by checking whether setup has already taken place. Setting onyx/max-peers 1 is not sufficient as a peer my crash and a new peer may start on that task. I don't recommend this approach unless it's a last resort.

As for teardown, the best approach is to setup a future that calls await-job-completion and perform the job teardown after await-job-completion completes. An alternative here is for a process to monitor the coordination log and perform teardown tasks on seeing certain job events. Note that this approach will not work for job setup.

I have some thoughts around work we could do in this area, however it is not currently a priority. I would especially like to cover  teardown on job completion, as it is harder to ensure that the process that started the job is still around on job completion.

Lucas
Reply all
Reply to author
Forward
0 new messages