Page 1 of 1

Automate server shutdown when no jobs are running

Posted: Mon Jun 27, 2022 12:07 pm
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?

Re: Automate server shutdown when no jobs are running

Posted: Mon Jun 27, 2022 12:18 pm
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

Re: Automate server shutdown when no jobs are running

Posted: Tue Jun 28, 2022 5:19 am
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. ;)

Re: Automate server shutdown when no jobs are running

Posted: Tue Jun 28, 2022 6:30 am
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...