2

I would like to run a batch application (that is a short lived process that should not be restarted) on Pivotal CloudFoundry.

I am not sure how to do that. My current batch app is restarted repeatedly by Pivotal CF.

It seems there's a new CF primitive called a task - as opposed to a long-running process. Tasks are supposed to be available on CF 1.7 (see https://stackoverflow.com/a/35512113/536299).

I was neither able to find relevant information in the CF documentation nor to figure out which version of the Pivotal CF is currently being run...

Can someone please help?

Community
  • 1
  • 1
balteo
  • 23,602
  • 63
  • 219
  • 412
  • here is a link about tasks in diego (guaranteed to run only once). Yet I have never tried this before. – user152468 Jul 11 '16 at 18:51
  • @user152468 Hi! Where's the link? – balteo Jul 11 '16 at 18:51
  • https://github.com/cloudfoundry/diego-design-notes – user152468 Jul 11 '16 at 18:59
  • 1
    Seems like when you push an app, the staging of the app becomes a task on Diego. Yet the link does not tell how to submit other tasks. – user152468 Jul 11 '16 at 19:05
  • Thanks for the link. However, it seems according to this link: http://stackoverflow.com/a/35512113/536299 that batch apps require tasks to be "exposed" whereas the tasks mentioned in the diego-design-notes seem not to be "exposed"... What are your thoughts about this? – balteo Jul 11 '16 at 19:08
  • 1
    New to me. This seems to be part of the v3 api. This api is documented here http://v3-apidocs.cloudfoundry.org/version/release-candidate/index.html#the-task-object . Does not seem to be released yet. – user152468 Jul 11 '16 at 19:16
  • The api states that you can only run a task for an app. There is no way of running a task without access to an app. So instead of running the task via the task api, you could also ssh into the app (cf ssh) and run it from there. Or you could expose a rest endpoint through your app that allows to run a task. – user152468 Jul 11 '16 at 19:20
  • I was looking for the v3 API. Thanks for that. I also asked for tips from PWS support staff. I'll include here any relevant information I obtain from them. – balteo Jul 11 '16 at 19:34

1 Answers1

2

I just got relevant information regarding short-lived/one-off processes on CF. It currently seems to be very difficult to run short-lived/one-off processes on CF.

This will change when CF v3's tasks becomes generally available.

Here is the information I was given:

Batch jobs are a little tricky on PWS and PCF because at the moment the platform expects your application to continue running forever. Even if the app exits successfully, the platform considers it to have crashed and will restart it. There is support in v3 of the platform for one-off tasks like batch jobs, so this will get easier in the future. For now, what you need to do is to make the app run forever. One option is to add a loop to the main method in the app, the loop would essentially run the batch job, pause for some set amount of time and repeat indefinitely.

So bottom-line is wait for CF v3's tasks.

See here for documentation about tasks: http://v3-apidocs.cloudfoundry.org/version/release-candidate/index.html#tasks

balteo
  • 23,602
  • 63
  • 219
  • 412
  • Questions about the "loop" workaround : does it require your app to be a web application, or a classic process fired from the command line enough ? Also, how would you schedule such a job ? by restarting the instance periodically ? – Michael Técourt Oct 20 '16 at 10:16