Automate server shutdown when no jobs are running

Questions and answers on how to get the most out of FFAStrans
Post Reply
catmur
Posts: 2
Joined: Mon Jun 27, 2022 11:54 am

Automate server shutdown when no jobs are running

Post by catmur »

Hi,

We are trying to automated the startup/shutdown of our FFAStrans server.

When content is found in a specific folder, we can trigger the start-up of our FFAStrans server, but i need a reliable way to query FFAStrans to see if there are any active Jobs being worked on.

If i can use the API to query and check that no jobs are running i can automate server shutdown when the server is not in use.

In the API documentation i can see i can get lists of workflows, and i can get the status for specific jobs http://<servername/ip>:65445/api/v2/jobs/<job_id>, but I can't see any API call to list all jobs?

Any pointers?
catmur
Posts: 2
Joined: Mon Jun 27, 2022 11:54 am

Re: Automate server shutdown when no jobs are running

Post by catmur »

I may have just answered my own question...

It seems querying http://<servername/ip>:65445/api/v2/jobs/ (without the specific job_id) outputs a list of jobs
User avatar
FranceBB
Posts: 235
Joined: Sat Jun 25, 2016 3:43 pm
Contact:

Re: Automate server shutdown when no jobs are running

Post by FranceBB »

catmur wrote: Mon Jun 27, 2022 12:18 pm I may have just answered my own question...

It seems querying http://<servername/ip>:65445/api/v2/jobs/ (without the specific job_id) outputs a list of jobs
Yes it does, that way you can see all jobs running in your farm.
It's funny that you mentioned spinning machines up and down cause that's what we do in the cloud.
You see, we have two different installations: one on prem with several bare metal machines constantly checking watchfolders and one in the cloud with sdvi as orchestrator.
We have 70 VMs on AWS that get spinned up, perform the job, tell the supply chain that they finished what they had to do and spin down till it's time to do another job, so I can tell you that not only it's doable but if you create an image that you can use in a VM you can make it elastic and spin up as many FFAStrans instances as you need while jobs are needed to be performed. ;)
emcodem
Posts: 1652
Joined: Wed Sep 19, 2018 8:11 am

Re: Automate server shutdown when no jobs are running

Post by emcodem »

I think for this usecase, i would go for the /tickets call instead of the jobs one.
http://FFASTRANS_HOST:65445/api/json/v2/tickets

The difference simple explained is that jobs only shows stuff that has already been picked up by some processor and tickets shows both, stuff that should be picked up by processors and stuff that has already been picked up.
But after all the difference might be marginal, as you need to implement some tolerance anyways, e.g. only shut down if there was no active job for 30 seconds or such...
emcodem, wrapping since 2009 you got the rhyme?
Post Reply